// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
parcelRequire = (function (modules, cache, entry, globalName) {
  // Save the require from previous bundle to this closure if any
  var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
  var nodeRequire = typeof require === 'function' && require;

  function newRequire(name, jumped) {
    if (!cache[name]) {
      if (!modules[name]) {
        // if we cannot find the module within our internal map or
        // cache jump to the current global require ie. the last bundle
        // that was added to the page.
        var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
        if (!jumped && currentRequire) {
          return currentRequire(name, true);
        }

        // If there are other bundles on this page the require from the
        // previous one is saved to 'previousRequire'. Repeat this as
        // many times as there are bundles until the module is found or
        // we exhaust the require chain.
        if (previousRequire) {
          return previousRequire(name, true);
        }

        // Try the node require function if it exists.
        if (nodeRequire && typeof name === 'string') {
          return nodeRequire(name);
        }

        var err = new Error('Cannot find module \'' + name + '\'');
        err.code = 'MODULE_NOT_FOUND';
        throw err;
      }

      localRequire.resolve = resolve;
      localRequire.cache = {};

      var module = cache[name] = new newRequire.Module(name);

      modules[name][0].call(module.exports, localRequire, module, module.exports, this);
    }

    return cache[name].exports;

    function localRequire(x){
      return newRequire(localRequire.resolve(x));
    }

    function resolve(x){
      return modules[name][1][x] || x;
    }
  }

  function Module(moduleName) {
    this.id = moduleName;
    this.bundle = newRequire;
    this.exports = {};
  }

  newRequire.isParcelRequire = true;
  newRequire.Module = Module;
  newRequire.modules = modules;
  newRequire.cache = cache;
  newRequire.parent = previousRequire;
  newRequire.register = function (id, exports) {
    modules[id] = [function (require, module) {
      module.exports = exports;
    }, {}];
  };

  var error;
  for (var i = 0; i < entry.length; i++) {
    try {
      newRequire(entry[i]);
    } catch (e) {
      // Save first error but execute all entries
      if (!error) {
        error = e;
      }
    }
  }

  if (entry.length) {
    // Expose entry point to Node, AMD or browser globals
    // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
    var mainExports = newRequire(entry[entry.length - 1]);

    // CommonJS
    if (typeof exports === "object" && typeof module !== "undefined") {
      module.exports = mainExports;

    // RequireJS
    } else if (typeof define === "function" && define.amd) {
     define(function () {
       return mainExports;
     });

    // <script>
    } else if (globalName) {
      this[globalName] = mainExports;
    }
  }

  // Override the current require with this new one
  parcelRequire = newRequire;

  if (error) {
    // throw error from earlier, _after updating parcelRequire_
    throw error;
  }

  return newRequire;
})({"node_modules/tslib/tslib.es6.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.__extends = __extends;
exports.__rest = __rest;
exports.__decorate = __decorate;
exports.__param = __param;
exports.__metadata = __metadata;
exports.__awaiter = __awaiter;
exports.__generator = __generator;
exports.__exportStar = __exportStar;
exports.__values = __values;
exports.__read = __read;
exports.__spread = __spread;
exports.__spreadArrays = __spreadArrays;
exports.__await = __await;
exports.__asyncGenerator = __asyncGenerator;
exports.__asyncDelegator = __asyncDelegator;
exports.__asyncValues = __asyncValues;
exports.__makeTemplateObject = __makeTemplateObject;
exports.__importStar = __importStar;
exports.__importDefault = __importDefault;
exports.__classPrivateFieldGet = __classPrivateFieldGet;
exports.__classPrivateFieldSet = __classPrivateFieldSet;
exports.__assign = void 0;

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */

/* global Reflect, Promise */
var extendStatics = function (d, b) {
  extendStatics = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (d, b) {
    d.__proto__ = b;
  } || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  };

  return extendStatics(d, b);
};

function __extends(d, b) {
  extendStatics(d, b);

  function __() {
    this.constructor = d;
  }

  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = function () {
  exports.__assign = __assign = Object.assign || function __assign(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

exports.__assign = __assign;

function __rest(s, e) {
  var t = {};

  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
}

function __decorate(decorators, target, key, desc) {
  var c = arguments.length,
      r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
      d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __param(paramIndex, decorator) {
  return function (target, key) {
    decorator(target, key, paramIndex);
  };
}

function __metadata(metadataKey, metadataValue) {
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}

function __awaiter(thisArg, _arguments, P, generator) {
  function adopt(value) {
    return value instanceof P ? value : new P(function (resolve) {
      resolve(value);
    });
  }

  return new (P || (P = Promise))(function (resolve, reject) {
    function fulfilled(value) {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    }

    function rejected(value) {
      try {
        step(generator["throw"](value));
      } catch (e) {
        reject(e);
      }
    }

    function step(result) {
      result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
    }

    step((generator = generator.apply(thisArg, _arguments || [])).next());
  });
}

function __generator(thisArg, body) {
  var _ = {
    label: 0,
    sent: function () {
      if (t[0] & 1) throw t[1];
      return t[1];
    },
    trys: [],
    ops: []
  },
      f,
      y,
      t,
      g;
  return g = {
    next: verb(0),
    "throw": verb(1),
    "return": verb(2)
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
    return this;
  }), g;

  function verb(n) {
    return function (v) {
      return step([n, v]);
    };
  }

  function step(op) {
    if (f) throw new TypeError("Generator is already executing.");

    while (_) try {
      if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
      if (y = 0, t) op = [op[0] & 2, t.value];

      switch (op[0]) {
        case 0:
        case 1:
          t = op;
          break;

        case 4:
          _.label++;
          return {
            value: op[1],
            done: false
          };

        case 5:
          _.label++;
          y = op[1];
          op = [0];
          continue;

        case 7:
          op = _.ops.pop();

          _.trys.pop();

          continue;

        default:
          if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
            _ = 0;
            continue;
          }

          if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
            _.label = op[1];
            break;
          }

          if (op[0] === 6 && _.label < t[1]) {
            _.label = t[1];
            t = op;
            break;
          }

          if (t && _.label < t[2]) {
            _.label = t[2];

            _.ops.push(op);

            break;
          }

          if (t[2]) _.ops.pop();

          _.trys.pop();

          continue;
      }

      op = body.call(thisArg, _);
    } catch (e) {
      op = [6, e];
      y = 0;
    } finally {
      f = t = 0;
    }

    if (op[0] & 5) throw op[1];
    return {
      value: op[0] ? op[1] : void 0,
      done: true
    };
  }
}

function __exportStar(m, exports) {
  for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}

function __values(o) {
  var s = typeof Symbol === "function" && Symbol.iterator,
      m = s && o[s],
      i = 0;
  if (m) return m.call(o);
  if (o && typeof o.length === "number") return {
    next: function () {
      if (o && i >= o.length) o = void 0;
      return {
        value: o && o[i++],
        done: !o
      };
    }
  };
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

function __read(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m) return o;
  var i = m.call(o),
      r,
      ar = [],
      e;

  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  } catch (error) {
    e = {
      error: error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"])) m.call(i);
    } finally {
      if (e) throw e.error;
    }
  }

  return ar;
}

function __spread() {
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));

  return ar;
}

function __spreadArrays() {
  for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;

  for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];

  return r;
}

;

function __await(v) {
  return this instanceof __await ? (this.v = v, this) : new __await(v);
}

function __asyncGenerator(thisArg, _arguments, generator) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var g = generator.apply(thisArg, _arguments || []),
      i,
      q = [];
  return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
    return this;
  }, i;

  function verb(n) {
    if (g[n]) i[n] = function (v) {
      return new Promise(function (a, b) {
        q.push([n, v, a, b]) > 1 || resume(n, v);
      });
    };
  }

  function resume(n, v) {
    try {
      step(g[n](v));
    } catch (e) {
      settle(q[0][3], e);
    }
  }

  function step(r) {
    r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  }

  function fulfill(value) {
    resume("next", value);
  }

  function reject(value) {
    resume("throw", value);
  }

  function settle(f, v) {
    if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  }
}

function __asyncDelegator(o) {
  var i, p;
  return i = {}, verb("next"), verb("throw", function (e) {
    throw e;
  }), verb("return"), i[Symbol.iterator] = function () {
    return this;
  }, i;

  function verb(n, f) {
    i[n] = o[n] ? function (v) {
      return (p = !p) ? {
        value: __await(o[n](v)),
        done: n === "return"
      } : f ? f(v) : v;
    } : f;
  }
}

function __asyncValues(o) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var m = o[Symbol.asyncIterator],
      i;
  return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
    return this;
  }, i);

  function verb(n) {
    i[n] = o[n] && function (v) {
      return new Promise(function (resolve, reject) {
        v = o[n](v), settle(resolve, reject, v.done, v.value);
      });
    };
  }

  function settle(resolve, reject, d, v) {
    Promise.resolve(v).then(function (v) {
      resolve({
        value: v,
        done: d
      });
    }, reject);
  }
}

function __makeTemplateObject(cooked, raw) {
  if (Object.defineProperty) {
    Object.defineProperty(cooked, "raw", {
      value: raw
    });
  } else {
    cooked.raw = raw;
  }

  return cooked;
}

;

function __importStar(mod) {
  if (mod && mod.__esModule) return mod;
  var result = {};
  if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  result.default = mod;
  return result;
}

function __importDefault(mod) {
  return mod && mod.__esModule ? mod : {
    default: mod
  };
}

function __classPrivateFieldGet(receiver, privateMap) {
  if (!privateMap.has(receiver)) {
    throw new TypeError("attempted to get private field on non-instance");
  }

  return privateMap.get(receiver);
}

function __classPrivateFieldSet(receiver, privateMap, value) {
  if (!privateMap.has(receiver)) {
    throw new TypeError("attempted to set private field on non-instance");
  }

  privateMap.set(receiver, value);
  return value;
}
},{}],"node_modules/inject-provide/lib/inject.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Inject = Inject;
exports.AutoInject = AutoInject;

var _store = require("./store");

var __read = void 0 && (void 0).__read || function (o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m) return o;
  var i = m.call(o),
      r,
      ar = [],
      e;

  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  } catch (error) {
    e = {
      error: error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"])) m.call(i);
    } finally {
      if (e) throw e.error;
    }
  }

  return ar;
};

var __spread = void 0 && (void 0).__spread || function () {
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));

  return ar;
};

function Inject(injectTarget, store) {
  var safeStore = store || _store.rootStore;
  var targetValue = safeStore.get(injectTarget);

  if (targetValue === null) {
    throw new Error("No such value has been provided");
  }

  return function (target, propertyKey, paramterIndex) {
    if (!target.__injectedData) {
      target.__injectedData = [];
    }

    target.__injectedData[paramterIndex] = targetValue;
  };
}

function AutoInject(target) {
  var params = [];

  for (var _i = 1; _i < arguments.length; _i++) {
    params[_i - 1] = arguments[_i];
  }

  var getConstructor = function (target) {
    if (target.prototype && target.prototype.constructor) {
      return target.prototype.constructor;
    } else if (target.constructor) {
      return target.constructor;
    }

    return target;
  };

  var getInjectedData = function (target) {
    if (target.__injectedData) {
      return target.__injectedData;
    } else if (target.prototype && target.prototype.__injectedData) {
      return target.__injectedData;
    } else if (target.prototype && target.prototype.constructor && target.prototype.constructor.__injectedData) {
      return target.prototype.constructor.__injectedData;
    }

    return null;
  };

  var targetCons = getConstructor(target);
  var injectedData = getInjectedData(target);

  if (injectedData === null) {
    return new (targetCons.bind.apply(targetCons, __spread([void 0], params)))();
  }

  return new (targetCons.bind.apply(targetCons, __spread([void 0], injectedData, params)))();
}
},{"./store":"node_modules/inject-provide/lib/store.js"}],"node_modules/inject-provide/lib/utils.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getParameterName = getParameterName;
exports.getSafeName = getSafeName;
exports.deepClone = deepClone;
exports.isArrayStore = isArrayStore;
exports.checkStore = checkStore;
exports.getSafeValue = getSafeValue;
exports.checkOptions = checkOptions;
exports.getOptionName = getOptionName;
exports.getOptionStore = getOptionStore;
exports.provideMethodName = provideMethodName;
exports.md5 = md5;

var _store = require("./store");

var _inject = require("./inject");

var __read = void 0 && (void 0).__read || function (o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m) return o;
  var i = m.call(o),
      r,
      ar = [],
      e;

  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  } catch (error) {
    e = {
      error: error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"])) m.call(i);
    } finally {
      if (e) throw e.error;
    }
  }

  return ar;
};

var __spread = void 0 && (void 0).__spread || function () {
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));

  return ar;
};

function getParameterName(targetFunc) {
  var fatArrows = /=>.*$/gm;
  var defaultParams = /=[^,)]+/gm;
  var comments = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
  var code = targetFunc.prototype ? targetFunc.prototype.constructor.toString() : targetFunc.toString();
  var result = code.replace(comments, "").replace(fatArrows, "").replace(defaultParams, "").slice(code.indexOf("(") + 1, code.indexOf(")")).match(/([^\s,]+)/g);
  return result === null ? [] : result;
}

function getSafeName(target) {
  var targetName = typeof target === "object" ? JSON.stringify(target) : String(target);
  return md5(targetName);
}

function deepClone(target) {
  var result;

  if (typeof target === "object") {
    if (Array.isArray(target)) {
      result = [];

      for (var i in target) {
        result.push(deepClone(target[i]));
      }
    } else if (target === null) {
      result = null;
    } else if (target.constructor === RegExp) {
      result = target;
    } else {
      result = {};

      for (var i in target) {
        result[i] = deepClone(target[i]);
      }
    }
  } else {
    result = target;
  }

  return result;
}

function isArrayStore(store) {
  return Object.prototype.toString.call(store) === "[object Array]";
}

function checkStore(store) {
  if (isArrayStore(store)) {
    for (var i in store) {
      if (store[i] instanceof _store.Store === false) {
        return false;
      }
    }

    return true;
  } else {
    if (store instanceof _store.Store === false) {
      return false;
    }

    return true;
  }
}

function getSafeValue(target, options) {
  var value;

  if (typeof target === "function") {
    if (options === undefined || options.pure === undefined || options.pure !== undefined && options.pure === false) {
      value = options && options.args ? _inject.AutoInject.apply(void 0, __spread([target], options.args)) : (0, _inject.AutoInject)(target);
    } else {
      value = target;
    }
  } else {
    value = target;
  }

  return value;
}

function checkOptions(options) {
  if (options !== undefined && options.store !== undefined && checkStore(options.store) === false) {
    return true;
  }

  return false;
}

function getOptionName(target, options) {
  return options && options.name ? getSafeName(options.name) : getSafeName(target);
}

function getOptionStore(options) {
  return options && options.store ? options.store : _store.rootStore;
}

function provideMethodName(target, propertyKey, descriptor) {
  var targetName = target.constructor ? getSafeName(target.constructor.toString()) : getSafeName(target);

  if (propertyKey === undefined || descriptor === undefined) {
    return targetName;
  }

  return getSafeName(targetName + "/" + propertyKey + "/" + descriptor.value.toString());
}

function md5(value) {
  function md5_RotateLeft(lValue, iShiftBits) {
    return lValue << iShiftBits | lValue >>> 32 - iShiftBits;
  }

  function md5_AddUnsigned(lX, lY) {
    var lX4, lY4, lX8, lY8, lResult;
    lX8 = lX & 0x80000000;
    lY8 = lY & 0x80000000;
    lX4 = lX & 0x40000000;
    lY4 = lY & 0x40000000;
    lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);

    if (lX4 & lY4) {
      return lResult ^ 0x80000000 ^ lX8 ^ lY8;
    }

    if (lX4 | lY4) {
      if (lResult & 0x40000000) {
        return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
      } else {
        return lResult ^ 0x40000000 ^ lX8 ^ lY8;
      }
    } else {
      return lResult ^ lX8 ^ lY8;
    }
  }

  function md5_F(x, y, z) {
    return x & y | ~x & z;
  }

  function md5_G(x, y, z) {
    return x & z | y & ~z;
  }

  function md5_H(x, y, z) {
    return x ^ y ^ z;
  }

  function md5_I(x, y, z) {
    return y ^ (x | ~z);
  }

  function md5_FF(a, b, c, d, x, s, ac) {
    a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_F(b, c, d), x), ac));
    return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  }

  function md5_GG(a, b, c, d, x, s, ac) {
    a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_G(b, c, d), x), ac));
    return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  }

  function md5_HH(a, b, c, d, x, s, ac) {
    a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_H(b, c, d), x), ac));
    return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  }

  function md5_II(a, b, c, d, x, s, ac) {
    a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_I(b, c, d), x), ac));
    return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  }

  function md5_ConvertToWordArray(value) {
    var lWordCount;
    var lMessageLength = value.length;
    var lNumberOfWords_temp1 = lMessageLength + 8;
    var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - lNumberOfWords_temp1 % 64) / 64;
    var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
    var lWordArray = Array(lNumberOfWords - 1);
    var lBytePosition = 0;
    var lByteCount = 0;

    while (lByteCount < lMessageLength) {
      lWordCount = (lByteCount - lByteCount % 4) / 4;
      lBytePosition = lByteCount % 4 * 8;
      lWordArray[lWordCount] = lWordArray[lWordCount] | value.charCodeAt(lByteCount) << lBytePosition;
      lByteCount++;
    }

    lWordCount = (lByteCount - lByteCount % 4) / 4;
    lBytePosition = lByteCount % 4 * 8;
    lWordArray[lWordCount] = lWordArray[lWordCount] | 0x80 << lBytePosition;
    lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
    lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
    return lWordArray;
  }

  function md5_WordToHex(lValue) {
    var WordToHexValue = "",
        WordToHexValue_temp = "",
        lByte,
        lCount;

    for (lCount = 0; lCount <= 3; lCount++) {
      lByte = lValue >>> lCount * 8 & 255;
      WordToHexValue_temp = "0" + lByte.toString(16);
      WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
    }

    return WordToHexValue;
  }

  function md5_Utf8Encode(val) {
    val = val.replace(/\r\n/g, "\n");
    var utftext = "";

    for (var n = 0; n < val.length; n++) {
      var c_1 = val.charCodeAt(n);

      if (c_1 < 128) {
        utftext += String.fromCharCode(c_1);
      } else if (c_1 > 127 && c_1 < 2048) {
        utftext += String.fromCharCode(c_1 >> 6 | 192);
        utftext += String.fromCharCode(c_1 & 63 | 128);
      } else {
        utftext += String.fromCharCode(c_1 >> 12 | 224);
        utftext += String.fromCharCode(c_1 >> 6 & 63 | 128);
        utftext += String.fromCharCode(c_1 & 63 | 128);
      }
    }

    return utftext;
  }

  var x = [];
  var k, AA, BB, CC, DD, a, b, c, d;
  var S11 = 7,
      S12 = 12,
      S13 = 17,
      S14 = 22;
  var S21 = 5,
      S22 = 9,
      S23 = 14,
      S24 = 20;
  var S31 = 4,
      S32 = 11,
      S33 = 16,
      S34 = 23;
  var S41 = 6,
      S42 = 10,
      S43 = 15,
      S44 = 21;
  value = md5_Utf8Encode(value);
  x = md5_ConvertToWordArray(value);
  a = 0x67452301;
  b = 0xefcdab89;
  c = 0x98badcfe;
  d = 0x10325476;

  for (k = 0; k < x.length; k += 16) {
    AA = a;
    BB = b;
    CC = c;
    DD = d;
    a = md5_FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
    d = md5_FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
    c = md5_FF(c, d, a, b, x[k + 2], S13, 0x242070db);
    b = md5_FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
    a = md5_FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
    d = md5_FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
    c = md5_FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
    b = md5_FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
    a = md5_FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
    d = md5_FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
    c = md5_FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
    b = md5_FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
    a = md5_FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
    d = md5_FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
    c = md5_FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
    b = md5_FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
    a = md5_GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
    d = md5_GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
    c = md5_GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
    b = md5_GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
    a = md5_GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
    d = md5_GG(d, a, b, c, x[k + 10], S22, 0x2441453);
    c = md5_GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
    b = md5_GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
    a = md5_GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
    d = md5_GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
    c = md5_GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
    b = md5_GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
    a = md5_GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
    d = md5_GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
    c = md5_GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
    b = md5_GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
    a = md5_HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
    d = md5_HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
    c = md5_HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
    b = md5_HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
    a = md5_HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
    d = md5_HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
    c = md5_HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
    b = md5_HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
    a = md5_HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
    d = md5_HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
    c = md5_HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
    b = md5_HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
    a = md5_HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
    d = md5_HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
    c = md5_HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
    b = md5_HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
    a = md5_II(a, b, c, d, x[k + 0], S41, 0xf4292244);
    d = md5_II(d, a, b, c, x[k + 7], S42, 0x432aff97);
    c = md5_II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
    b = md5_II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
    a = md5_II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
    d = md5_II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
    c = md5_II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
    b = md5_II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
    a = md5_II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
    d = md5_II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
    c = md5_II(c, d, a, b, x[k + 6], S43, 0xa3014314);
    b = md5_II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
    a = md5_II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
    d = md5_II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
    c = md5_II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
    b = md5_II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
    a = md5_AddUnsigned(a, AA);
    b = md5_AddUnsigned(b, BB);
    c = md5_AddUnsigned(c, CC);
    d = md5_AddUnsigned(d, DD);
  }

  return (md5_WordToHex(a) + md5_WordToHex(b) + md5_WordToHex(c) + md5_WordToHex(d)).toLowerCase();
}
},{"./store":"node_modules/inject-provide/lib/store.js","./inject":"node_modules/inject-provide/lib/inject.js"}],"node_modules/inject-provide/lib/store.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.rootStore = exports.createStore = exports.storeController = exports.Store = void 0;

var _utils = require("./utils");

var Store = function () {
  function Store(name) {
    this.name = name;
    this.items = [];
  }

  Store.prototype.add = function (item) {
    this.items.push(item);
  };

  Store.prototype.exist = function (target) {
    var safeName = (0, _utils.getSafeName)(target);

    for (var i in this.items) {
      if (this.items[i].name === safeName) return true;
    }

    return false;
  };

  Store.prototype.get = function (target, useHash) {
    if (useHash === void 0) {
      useHash = true;
    }

    var safeName = useHash ? (0, _utils.getSafeName)(target) : target;

    for (var i in this.items) {
      if (this.items[i].name === safeName) return this.items[i].value;
    }

    return null;
  };

  return Store;
}();

exports.Store = Store;

var StoreController = function () {
  function StoreController() {
    this.stores = [];
  }

  StoreController.prototype.is = function (item) {
    return item instanceof Store;
  };

  StoreController.prototype.add = function (item) {
    this.stores.push(item);
  };

  StoreController.prototype.create = function () {
    return createStore();
  };

  StoreController.prototype.count = function () {
    return this.stores.length;
  };

  StoreController.prototype.exist = function (storeOrName) {
    var name = typeof storeOrName === "object" ? storeOrName.name : storeOrName;

    for (var i in this.stores) {
      if (this.stores[i].name === name) return true;
    }

    return false;
  };

  return StoreController;
}();

var storeController = new StoreController();
exports.storeController = storeController;

var createStore = function () {
  var hashName = (0, _utils.md5)("new Store()/atPosition/" + storeController.count());
  var store = new Store(hashName);
  storeController.add(store);
  return store;
};

exports.createStore = createStore;
var rootStore = createStore();
exports.rootStore = rootStore;
},{"./utils":"node_modules/inject-provide/lib/utils.js"}],"node_modules/inject-provide/lib/event.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createEvent = createEvent;
exports.EventInjector = exports.EventController = exports.StoreEmitter = void 0;

var _store = require("./store");

var _inject = require("./inject");

var _utils = require("./utils");

var __read = void 0 && (void 0).__read || function (o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m) return o;
  var i = m.call(o),
      r,
      ar = [],
      e;

  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  } catch (error) {
    e = {
      error: error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"])) m.call(i);
    } finally {
      if (e) throw e.error;
    }
  }

  return ar;
};

var __spread = void 0 && (void 0).__spread || function () {
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));

  return ar;
};

var StoreEmitter = function () {
  function StoreEmitter(storeItem) {
    this.storeItem = storeItem;
  }

  StoreEmitter.prototype.emit = function () {
    var args = [];

    for (var _i = 0; _i < arguments.length; _i++) {
      args[_i] = arguments[_i];
    }

    this.storeItem.forEach(function (item) {
      var _a;

      if (item.value["target"] && item.value["propertyKey"]) {
        var target = item.value["target"];
        var propertyKey = item.value["propertyKey"];

        if (target[propertyKey] !== undefined) {
          (_a = target[propertyKey]).call.apply(_a, __spread([target], args));
        }
      }
    });
  };

  return StoreEmitter;
}();

exports.StoreEmitter = StoreEmitter;

var EventController = function () {
  function EventController(store) {
    this.store = store;
  }

  EventController.prototype.emit = function () {
    var _a;

    var args = [];

    for (var _i = 0; _i < arguments.length; _i++) {
      args[_i] = arguments[_i];
    }

    return (_a = this.emitHook()).emit.apply(_a, __spread(args));
  };

  EventController.prototype.getStore = function () {
    return this.store;
  };

  EventController.prototype.includeTags = function (tag) {
    var checkTags = function (tagName) {
      if (typeof tag === "string") {
        return typeof tagName === "string" && tagName.includes(tag);
      } else {
        return typeof tagName === "string" && tag.includes(tagName);
      }

      return false;
    };

    var items = this.store.items.filter(function (item) {
      if (item.value.tag !== undefined) {
        return checkTags(item.value.tag);
      }

      return false;
    });
    return this.emitHook(items);
  };

  EventController.prototype.selectTags = function (tag) {
    var checkTags = function (tagName) {
      if (typeof tag === "string" || typeof tag === "object") {
        return tagName === tag;
      } else {
        return tag(tagName);
      }
    };

    var items = this.store.items.filter(function (item) {
      if (item.value.tag !== undefined) {
        return checkTags(item.value.tag);
      }

      return false;
    });
    return this.emitHook(items);
  };

  EventController.prototype.emitHook = function (items) {
    return new StoreEmitter(items ? items : this.store.items.filter(function (item) {
      return item.value.tag !== undefined;
    }));
  };

  return EventController;
}();

exports.EventController = EventController;

var EventInjector = function () {
  function EventInjector() {
    var _this = this;

    this.Subject = function () {
      var args = [];

      for (var _i = 0; _i < arguments.length; _i++) {
        args[_i] = arguments[_i];
      }

      return function (target) {
        var newTarget = _inject.AutoInject.apply(void 0, __spread([target], args));

        for (var i in _this.controller.getStore().items) {
          var item = _this.controller.getStore().items[i];

          if (item.value.target !== undefined && item.value.target.constructor !== undefined && item.value.propertyKey !== undefined && item.value.tag !== undefined) {
            if (String(item.value.target.constructor) === String(target)) {
              item.value.target = newTarget;
            }
          }
        }
      };
    };

    this.Provide = function () {
      return function (target, propertyKey, descriptor) {
        _this.store.add({
          name: (0, _utils.provideMethodName)(target, propertyKey, descriptor),
          value: {
            target: target,
            propertyKey: propertyKey,
            tag: null
          }
        });
      };
    };

    this.Tag = function (tag) {
      return function (target, propertyKey, descriptor) {
        var storeItemName = (0, _utils.provideMethodName)(target, propertyKey, descriptor);

        var noHashGetItem = _this.controller.getStore().get(storeItemName, false);

        if (noHashGetItem.tag !== undefined) {
          noHashGetItem.tag = tag || null;
        }
      };
    };

    this.store = (0, _store.createStore)();
    this.controller = new EventController(this.store);
  }

  return EventInjector;
}();

exports.EventInjector = EventInjector;

function createEvent() {
  return new EventInjector();
}
},{"./store":"node_modules/inject-provide/lib/store.js","./inject":"node_modules/inject-provide/lib/inject.js","./utils":"node_modules/inject-provide/lib/utils.js"}],"node_modules/inject-provide/lib/provide.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Offer = Offer;
exports.Provide = Provide;
exports.createToken = createToken;

var _utils = require("./utils");

function Offer(target, options) {
  if ((0, _utils.checkOptions)(options)) {
    throw new Error("invaild store is injected");
  }

  var safeValue = (0, _utils.getSafeValue)(target, options);
  var safeName = (0, _utils.getOptionName)(target, options);
  var safeStore = (0, _utils.getOptionStore)(options);

  if ((0, _utils.isArrayStore)(safeStore)) {
    for (var i in safeStore) {
      if (safeStore[i].exist(safeName)) {
        throw new Error("it can only provide a unique name");
      }

      safeStore[i].add({
        name: safeName,
        value: (0, _utils.deepClone)(safeValue)
      });
    }
  } else {
    if (safeStore.exist(safeName)) {
      throw new Error("it can only provide a unique name");
    }

    safeStore.add({
      name: safeName,
      value: (0, _utils.deepClone)(safeValue)
    });
  }
}

function Provide(options) {
  return function (target) {
    Offer(target, options);
  };
}

function createToken() {
  var randomNumber1 = Math.random();
  var randomNumber2 = Math.random() * Math.random();
  var randomNumber3 = Math.random() * new Date().getTime();
  return (0, _utils.getSafeName)(randomNumber1.toString() + "/" + randomNumber2.toString() + "/" + randomNumber3.toString());
}
},{"./utils":"node_modules/inject-provide/lib/utils.js"}],"node_modules/inject-provide/lib/index.js":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "createEvent", {
  enumerable: true,
  get: function () {
    return _event.createEvent;
  }
});
Object.defineProperty(exports, "EventController", {
  enumerable: true,
  get: function () {
    return _event.EventController;
  }
});
Object.defineProperty(exports, "EventInjector", {
  enumerable: true,
  get: function () {
    return _event.EventInjector;
  }
});
Object.defineProperty(exports, "StoreEmitter", {
  enumerable: true,
  get: function () {
    return _event.StoreEmitter;
  }
});
Object.defineProperty(exports, "AutoInject", {
  enumerable: true,
  get: function () {
    return _inject.AutoInject;
  }
});
Object.defineProperty(exports, "Inject", {
  enumerable: true,
  get: function () {
    return _inject.Inject;
  }
});
Object.defineProperty(exports, "createToken", {
  enumerable: true,
  get: function () {
    return _provide.createToken;
  }
});
Object.defineProperty(exports, "Offer", {
  enumerable: true,
  get: function () {
    return _provide.Offer;
  }
});
Object.defineProperty(exports, "Provide", {
  enumerable: true,
  get: function () {
    return _provide.Provide;
  }
});
Object.defineProperty(exports, "createStore", {
  enumerable: true,
  get: function () {
    return _store.createStore;
  }
});
Object.defineProperty(exports, "rootStore", {
  enumerable: true,
  get: function () {
    return _store.rootStore;
  }
});
Object.defineProperty(exports, "storeController", {
  enumerable: true,
  get: function () {
    return _store.storeController;
  }
});
Object.defineProperty(exports, "Store", {
  enumerable: true,
  get: function () {
    return _store.Store;
  }
});

var _event = require("./event");

var _inject = require("./inject");

var _provide = require("./provide");

var _store = require("./store");
},{"./event":"node_modules/inject-provide/lib/event.js","./inject":"node_modules/inject-provide/lib/inject.js","./provide":"node_modules/inject-provide/lib/provide.js","./store":"node_modules/inject-provide/lib/store.js"}],"src/zcp.ts":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ZCP = void 0;

var _tslib = require("tslib");

var _injectProvide = require("inject-provide");

var ZCP =
/** @class */
function () {
  function ZCP(arr) {
    this.result = [];

    if (arr) {
      this.result = this.getAllCorrectCards(arr);
    }
  }

  ZCP.prototype.sum = function (arr) {
    var s = 0;
    arr.forEach(function (v) {
      s += v;
    });
    return s;
  };

  ZCP.prototype.isEqual = function (arr1, arr2, hasSameValue) {
    if (hasSameValue === void 0) {
      hasSameValue = 0;
    }

    return Math.abs(this.sum(arr1) - this.sum(arr2)) === 0 || Math.abs(this.sum(arr1) - this.sum(arr2)) === 1 * hasSameValue || Math.abs(this.sum(arr1) - this.sum(arr2)) === 2 * hasSameValue;
  };

  ZCP.prototype.traveral = function (size, len) {
    var arr = Array(len).fill(0).map(function (_v, i) {
      return i;
    });
    var cards = [];

    (function traveral(arr, size, result) {
      var arrConcat = function (arr) {
        var result = [];
        arr.forEach(function (e) {
          e.forEach(function (v) {
            result.push(v);
          });
        });
        return result;
      };

      if (size > arr.length) {
        return;
      } else if (size === arr.length) {
        cards.push(arrConcat([result, arr]));
      } else {
        for (var i = 0; i < arr.length; i++) {
          var temp = arrConcat([result]);
          temp.push(arr[i]);

          if (size === 1) {
            cards.push(temp);
          } else {
            var tempArr = arrConcat([arr]);
            tempArr.splice(0, i + 1);
            traveral(tempArr, size - 1, temp);
          }
        }
      }
    })(arr, size, []);

    return cards;
  };

  ZCP.prototype.cardToNum = function (val) {
    var vaildChars = {
      J: 11,
      Q: 12,
      K: 13,
      j: 11,
      q: 12,
      k: 13
    };

    var isNumber = function (val) {
      var regNumber = /^\d+$/;

      if (regNumber.test(val)) {
        return true;
      } else {
        return false;
      }
    };

    if (isNumber(val.toString())) {
      return Number(val);
    } else if (Object.keys(vaildChars).includes(val.toString())) {
      var returns = 0;

      for (var i in Object.keys(vaildChars)) {
        if (Object.keys(vaildChars)[i] === val.toString()) {
          returns = Object.values(vaildChars)[i];
          break;
        }
      }

      return returns;
    } else {
      return -1;
    }
  };

  ZCP.prototype.numsToCard = function (val) {
    var strArr = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"];
    return strArr[val - 1];
  };

  ZCP.prototype.cardsToNums = function (val) {
    var _this = this;

    return val.map(function (e) {
      return _this.cardToNum(e);
    });
  };

  ZCP.prototype.allTraveral = function (len) {
    var result = [];

    for (var i = 1; i <= Math.floor(0.5 * len); i++) {
      this.traveral(i, len).forEach(function (e) {
        result.push(e);
      });
    }

    return result;
  };

  ZCP.prototype.chooseCards = function (arr) {
    var result = [];
    var allVals = Array(arr.length).fill(0).map(function (_v, i) {
      return i;
    });
    this.allTraveral(arr.length).forEach(function (e) {
      var temp1 = [];
      var temp2 = [];
      e.forEach(function (v) {
        temp1.push(arr[v]);
      });
      allVals.forEach(function (v) {
        if (!e.includes(v)) {
          temp2.push(arr[v]);
        }
      });
      result.push([temp1, temp2]);
    });
    return result;
  };

  ZCP.prototype.getCorrectCards = function (arr, hasSameValue) {
    var _this = this;

    if (hasSameValue === void 0) {
      hasSameValue = 0;
    }

    var result = [];
    var allParts = this.chooseCards(arr);
    allParts.forEach(function (e) {
      if (_this.isEqual(_this.cardsToNums(e[0]), _this.cardsToNums(e[1]), hasSameValue)) {
        result.push(e);
      }
    });
    return result;
  };

  ZCP.prototype.getAllCorrectCards = function (arr, hasSameValue) {
    var _this = this;

    if (hasSameValue === void 0) {
      hasSameValue = 0;
    }

    var result = this.getCorrectCards(arr, hasSameValue);
    var allParts = this.chooseCards(arr);
    allParts.forEach(function (e) {
      _this.getCorrectCards(e[0]).forEach(function (v) {
        result.push(v);
      });

      _this.getCorrectCards(e[1]).forEach(function (v) {
        result.push(v);
      });
    });
    return result;
  };

  ZCP.prototype.when = function (arr, hasSameValue) {
    if (hasSameValue === void 0) {
      hasSameValue = 0;
    }

    return this.getAllCorrectCards(arr, hasSameValue);
  };

  ZCP.prototype.filter = function (arr) {
    var isEqual = function (m, n) {
      if (m.length !== n.length) return false;
      var M = m.sort();
      var N = n.sort();
      var result = true;
      M.forEach(function (v, k) {
        if (v !== N[k]) {
          result = false;
        }
      });
      return result;
    };

    var itemsIsEqual = function (m, n) {
      if (isEqual(m[0], n[0]) && isEqual(m[1], n[1])) return true;
      if (isEqual(m[0], n[1]) && isEqual(m[1], n[0])) return true;
      return false;
    };

    var arrHasItem = function (m, n) {
      var result = false;
      n.forEach(function (v) {
        if (itemsIsEqual(v, m)) {
          result = true;
        }
      });
      return result;
    };

    var newArr = [];
    arr.forEach(function (v) {
      if (!arrHasItem(v, newArr)) {
        newArr.push(v);
      }
    });
    return newArr;
  };

  ZCP.prototype.sort = function (arr) {
    var sortByLength = function (m, n) {
      return n[0].length + n[1].length - m[0].length - m[1].length;
    };

    var sortByFirstLength = function (m, n) {
      return n[0].length - m[0].length;
    };

    return arr.sort(sortByFirstLength).sort(sortByLength);
  };

  ZCP = (0, _tslib.__decorate)([(0, _injectProvide.Provide)()], ZCP);
  return ZCP;
}();

exports.ZCP = ZCP;
},{"tslib":"node_modules/tslib/tslib.es6.js","inject-provide":"node_modules/inject-provide/lib/index.js"}],"node_modules/universalify/index.js":[function(require,module,exports) {
'use strict';

exports.fromCallback = function (fn) {
  return Object.defineProperty(function (...args) {
    if (typeof args[args.length - 1] === 'function') fn.apply(this, args);else {
      return new Promise((resolve, reject) => {
        fn.apply(this, args.concat([(err, res) => err ? reject(err) : resolve(res)]));
      });
    }
  }, 'name', {
    value: fn.name
  });
};

exports.fromPromise = function (fn) {
  return Object.defineProperty(function (...args) {
    const cb = args[args.length - 1];
    if (typeof cb !== 'function') return fn.apply(this, args);else fn.apply(this, args.slice(0, -1)).then(r => cb(null, r), cb);
  }, 'name', {
    value: fn.name
  });
};
},{}],"node_modules/graceful-fs/polyfills.js":[function(require,module,exports) {
var constants = require('constants')

var origCwd = process.cwd
var cwd = null

var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform

process.cwd = function() {
  if (!cwd)
    cwd = origCwd.call(process)
  return cwd
}
try {
  process.cwd()
} catch (er) {}

var chdir = process.chdir
process.chdir = function(d) {
  cwd = null
  chdir.call(process, d)
}

module.exports = patch

function patch (fs) {
  // (re-)implement some things that are known busted or missing.

  // lchmod, broken prior to 0.6.2
  // back-port the fix here.
  if (constants.hasOwnProperty('O_SYMLINK') &&
      process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
    patchLchmod(fs)
  }

  // lutimes implementation, or no-op
  if (!fs.lutimes) {
    patchLutimes(fs)
  }

  // https://github.com/isaacs/node-graceful-fs/issues/4
  // Chown should not fail on einval or eperm if non-root.
  // It should not fail on enosys ever, as this just indicates
  // that a fs doesn't support the intended operation.

  fs.chown = chownFix(fs.chown)
  fs.fchown = chownFix(fs.fchown)
  fs.lchown = chownFix(fs.lchown)

  fs.chmod = chmodFix(fs.chmod)
  fs.fchmod = chmodFix(fs.fchmod)
  fs.lchmod = chmodFix(fs.lchmod)

  fs.chownSync = chownFixSync(fs.chownSync)
  fs.fchownSync = chownFixSync(fs.fchownSync)
  fs.lchownSync = chownFixSync(fs.lchownSync)

  fs.chmodSync = chmodFixSync(fs.chmodSync)
  fs.fchmodSync = chmodFixSync(fs.fchmodSync)
  fs.lchmodSync = chmodFixSync(fs.lchmodSync)

  fs.stat = statFix(fs.stat)
  fs.fstat = statFix(fs.fstat)
  fs.lstat = statFix(fs.lstat)

  fs.statSync = statFixSync(fs.statSync)
  fs.fstatSync = statFixSync(fs.fstatSync)
  fs.lstatSync = statFixSync(fs.lstatSync)

  // if lchmod/lchown do not exist, then make them no-ops
  if (!fs.lchmod) {
    fs.lchmod = function (path, mode, cb) {
      if (cb) process.nextTick(cb)
    }
    fs.lchmodSync = function () {}
  }
  if (!fs.lchown) {
    fs.lchown = function (path, uid, gid, cb) {
      if (cb) process.nextTick(cb)
    }
    fs.lchownSync = function () {}
  }

  // on Windows, A/V software can lock the directory, causing this
  // to fail with an EACCES or EPERM if the directory contains newly
  // created files.  Try again on failure, for up to 60 seconds.

  // Set the timeout this long because some Windows Anti-Virus, such as Parity
  // bit9, may lock files for up to a minute, causing npm package install
  // failures. Also, take care to yield the scheduler. Windows scheduling gives
  // CPU to a busy looping process, which can cause the program causing the lock
  // contention to be starved of CPU by node, so the contention doesn't resolve.
  if (platform === "win32") {
    fs.rename = (function (fs$rename) { return function (from, to, cb) {
      var start = Date.now()
      var backoff = 0;
      fs$rename(from, to, function CB (er) {
        if (er
            && (er.code === "EACCES" || er.code === "EPERM")
            && Date.now() - start < 60000) {
          setTimeout(function() {
            fs.stat(to, function (stater, st) {
              if (stater && stater.code === "ENOENT")
                fs$rename(from, to, CB);
              else
                cb(er)
            })
          }, backoff)
          if (backoff < 100)
            backoff += 10;
          return;
        }
        if (cb) cb(er)
      })
    }})(fs.rename)
  }

  // if read() returns EAGAIN, then just try it again.
  fs.read = (function (fs$read) {
    function read (fd, buffer, offset, length, position, callback_) {
      var callback
      if (callback_ && typeof callback_ === 'function') {
        var eagCounter = 0
        callback = function (er, _, __) {
          if (er && er.code === 'EAGAIN' && eagCounter < 10) {
            eagCounter ++
            return fs$read.call(fs, fd, buffer, offset, length, position, callback)
          }
          callback_.apply(this, arguments)
        }
      }
      return fs$read.call(fs, fd, buffer, offset, length, position, callback)
    }

    // This ensures `util.promisify` works as it does for native `fs.read`.
    read.__proto__ = fs$read
    return read
  })(fs.read)

  fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
    var eagCounter = 0
    while (true) {
      try {
        return fs$readSync.call(fs, fd, buffer, offset, length, position)
      } catch (er) {
        if (er.code === 'EAGAIN' && eagCounter < 10) {
          eagCounter ++
          continue
        }
        throw er
      }
    }
  }})(fs.readSync)

  function patchLchmod (fs) {
    fs.lchmod = function (path, mode, callback) {
      fs.open( path
             , constants.O_WRONLY | constants.O_SYMLINK
             , mode
             , function (err, fd) {
        if (err) {
          if (callback) callback(err)
          return
        }
        // prefer to return the chmod error, if one occurs,
        // but still try to close, and report closing errors if they occur.
        fs.fchmod(fd, mode, function (err) {
          fs.close(fd, function(err2) {
            if (callback) callback(err || err2)
          })
        })
      })
    }

    fs.lchmodSync = function (path, mode) {
      var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)

      // prefer to return the chmod error, if one occurs,
      // but still try to close, and report closing errors if they occur.
      var threw = true
      var ret
      try {
        ret = fs.fchmodSync(fd, mode)
        threw = false
      } finally {
        if (threw) {
          try {
            fs.closeSync(fd)
          } catch (er) {}
        } else {
          fs.closeSync(fd)
        }
      }
      return ret
    }
  }

  function patchLutimes (fs) {
    if (constants.hasOwnProperty("O_SYMLINK")) {
      fs.lutimes = function (path, at, mt, cb) {
        fs.open(path, constants.O_SYMLINK, function (er, fd) {
          if (er) {
            if (cb) cb(er)
            return
          }
          fs.futimes(fd, at, mt, function (er) {
            fs.close(fd, function (er2) {
              if (cb) cb(er || er2)
            })
          })
        })
      }

      fs.lutimesSync = function (path, at, mt) {
        var fd = fs.openSync(path, constants.O_SYMLINK)
        var ret
        var threw = true
        try {
          ret = fs.futimesSync(fd, at, mt)
          threw = false
        } finally {
          if (threw) {
            try {
              fs.closeSync(fd)
            } catch (er) {}
          } else {
            fs.closeSync(fd)
          }
        }
        return ret
      }

    } else {
      fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
      fs.lutimesSync = function () {}
    }
  }

  function chmodFix (orig) {
    if (!orig) return orig
    return function (target, mode, cb) {
      return orig.call(fs, target, mode, function (er) {
        if (chownErOk(er)) er = null
        if (cb) cb.apply(this, arguments)
      })
    }
  }

  function chmodFixSync (orig) {
    if (!orig) return orig
    return function (target, mode) {
      try {
        return orig.call(fs, target, mode)
      } catch (er) {
        if (!chownErOk(er)) throw er
      }
    }
  }


  function chownFix (orig) {
    if (!orig) return orig
    return function (target, uid, gid, cb) {
      return orig.call(fs, target, uid, gid, function (er) {
        if (chownErOk(er)) er = null
        if (cb) cb.apply(this, arguments)
      })
    }
  }

  function chownFixSync (orig) {
    if (!orig) return orig
    return function (target, uid, gid) {
      try {
        return orig.call(fs, target, uid, gid)
      } catch (er) {
        if (!chownErOk(er)) throw er
      }
    }
  }

  function statFix (orig) {
    if (!orig) return orig
    // Older versions of Node erroneously returned signed integers for
    // uid + gid.
    return function (target, options, cb) {
      if (typeof options === 'function') {
        cb = options
        options = null
      }
      function callback (er, stats) {
        if (stats) {
          if (stats.uid < 0) stats.uid += 0x100000000
          if (stats.gid < 0) stats.gid += 0x100000000
        }
        if (cb) cb.apply(this, arguments)
      }
      return options ? orig.call(fs, target, options, callback)
        : orig.call(fs, target, callback)
    }
  }

  function statFixSync (orig) {
    if (!orig) return orig
    // Older versions of Node erroneously returned signed integers for
    // uid + gid.
    return function (target, options) {
      var stats = options ? orig.call(fs, target, options)
        : orig.call(fs, target)
      if (stats.uid < 0) stats.uid += 0x100000000
      if (stats.gid < 0) stats.gid += 0x100000000
      return stats;
    }
  }

  // ENOSYS means that the fs doesn't support the op. Just ignore
  // that, because it doesn't matter.
  //
  // if there's no getuid, or if getuid() is something other
  // than 0, and the error is EINVAL or EPERM, then just ignore
  // it.
  //
  // This specific case is a silent failure in cp, install, tar,
  // and most other unix tools that manage permissions.
  //
  // When running as root, or if other types of errors are
  // encountered, then it's strict.
  function chownErOk (er) {
    if (!er)
      return true

    if (er.code === "ENOSYS")
      return true

    var nonroot = !process.getuid || process.getuid() !== 0
    if (nonroot) {
      if (er.code === "EINVAL" || er.code === "EPERM")
        return true
    }

    return false
  }
}

},{}],"node_modules/graceful-fs/legacy-streams.js":[function(require,module,exports) {
var Stream = require('stream').Stream

module.exports = legacy

function legacy (fs) {
  return {
    ReadStream: ReadStream,
    WriteStream: WriteStream
  }

  function ReadStream (path, options) {
    if (!(this instanceof ReadStream)) return new ReadStream(path, options);

    Stream.call(this);

    var self = this;

    this.path = path;
    this.fd = null;
    this.readable = true;
    this.paused = false;

    this.flags = 'r';
    this.mode = 438; /*=0666*/
    this.bufferSize = 64 * 1024;

    options = options || {};

    // Mixin options into this
    var keys = Object.keys(options);
    for (var index = 0, length = keys.length; index < length; index++) {
      var key = keys[index];
      this[key] = options[key];
    }

    if (this.encoding) this.setEncoding(this.encoding);

    if (this.start !== undefined) {
      if ('number' !== typeof this.start) {
        throw TypeError('start must be a Number');
      }
      if (this.end === undefined) {
        this.end = Infinity;
      } else if ('number' !== typeof this.end) {
        throw TypeError('end must be a Number');
      }

      if (this.start > this.end) {
        throw new Error('start must be <= end');
      }

      this.pos = this.start;
    }

    if (this.fd !== null) {
      process.nextTick(function() {
        self._read();
      });
      return;
    }

    fs.open(this.path, this.flags, this.mode, function (err, fd) {
      if (err) {
        self.emit('error', err);
        self.readable = false;
        return;
      }

      self.fd = fd;
      self.emit('open', fd);
      self._read();
    })
  }

  function WriteStream (path, options) {
    if (!(this instanceof WriteStream)) return new WriteStream(path, options);

    Stream.call(this);

    this.path = path;
    this.fd = null;
    this.writable = true;

    this.flags = 'w';
    this.encoding = 'binary';
    this.mode = 438; /*=0666*/
    this.bytesWritten = 0;

    options = options || {};

    // Mixin options into this
    var keys = Object.keys(options);
    for (var index = 0, length = keys.length; index < length; index++) {
      var key = keys[index];
      this[key] = options[key];
    }

    if (this.start !== undefined) {
      if ('number' !== typeof this.start) {
        throw TypeError('start must be a Number');
      }
      if (this.start < 0) {
        throw new Error('start must be >= zero');
      }

      this.pos = this.start;
    }

    this.busy = false;
    this._queue = [];

    if (this.fd === null) {
      this._open = fs.open;
      this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
      this.flush();
    }
  }
}

},{}],"node_modules/graceful-fs/clone.js":[function(require,module,exports) {
'use strict'

module.exports = clone

function clone (obj) {
  if (obj === null || typeof obj !== 'object')
    return obj

  if (obj instanceof Object)
    var copy = { __proto__: obj.__proto__ }
  else
    var copy = Object.create(null)

  Object.getOwnPropertyNames(obj).forEach(function (key) {
    Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
  })

  return copy
}

},{}],"node_modules/graceful-fs/graceful-fs.js":[function(require,module,exports) {
var fs = require('fs')
var polyfills = require('./polyfills.js')
var legacy = require('./legacy-streams.js')
var clone = require('./clone.js')

var util = require('util')

/* istanbul ignore next - node 0.x polyfill */
var gracefulQueue
var previousSymbol

/* istanbul ignore else - node 0.x polyfill */
if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
  gracefulQueue = Symbol.for('graceful-fs.queue')
  // This is used in testing by future versions
  previousSymbol = Symbol.for('graceful-fs.previous')
} else {
  gracefulQueue = '___graceful-fs.queue'
  previousSymbol = '___graceful-fs.previous'
}

function noop () {}

var debug = noop
if (util.debuglog)
  debug = util.debuglog('gfs4')
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
  debug = function() {
    var m = util.format.apply(util, arguments)
    m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
    console.error(m)
  }

// Once time initialization
if (!global[gracefulQueue]) {
  // This queue can be shared by multiple loaded instances
  var queue = []
  Object.defineProperty(global, gracefulQueue, {
    get: function() {
      return queue
    }
  })

  // Patch fs.close/closeSync to shared queue version, because we need
  // to retry() whenever a close happens *anywhere* in the program.
  // This is essential when multiple graceful-fs instances are
  // in play at the same time.
  fs.close = (function (fs$close) {
    function close (fd, cb) {
      return fs$close.call(fs, fd, function (err) {
        // This function uses the graceful-fs shared queue
        if (!err) {
          retry()
        }

        if (typeof cb === 'function')
          cb.apply(this, arguments)
      })
    }

    Object.defineProperty(close, previousSymbol, {
      value: fs$close
    })
    return close
  })(fs.close)

  fs.closeSync = (function (fs$closeSync) {
    function closeSync (fd) {
      // This function uses the graceful-fs shared queue
      fs$closeSync.apply(fs, arguments)
      retry()
    }

    Object.defineProperty(closeSync, previousSymbol, {
      value: fs$closeSync
    })
    return closeSync
  })(fs.closeSync)

  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
    process.on('exit', function() {
      debug(global[gracefulQueue])
      require('assert').equal(global[gracefulQueue].length, 0)
    })
  }
}

module.exports = patch(clone(fs))
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
    module.exports = patch(fs)
    fs.__patched = true;
}

function patch (fs) {
  // Everything that references the open() function needs to be in here
  polyfills(fs)
  fs.gracefulify = patch

  fs.createReadStream = createReadStream
  fs.createWriteStream = createWriteStream
  var fs$readFile = fs.readFile
  fs.readFile = readFile
  function readFile (path, options, cb) {
    if (typeof options === 'function')
      cb = options, options = null

    return go$readFile(path, options, cb)

    function go$readFile (path, options, cb) {
      return fs$readFile(path, options, function (err) {
        if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
          enqueue([go$readFile, [path, options, cb]])
        else {
          if (typeof cb === 'function')
            cb.apply(this, arguments)
          retry()
        }
      })
    }
  }

  var fs$writeFile = fs.writeFile
  fs.writeFile = writeFile
  function writeFile (path, data, options, cb) {
    if (typeof options === 'function')
      cb = options, options = null

    return go$writeFile(path, data, options, cb)

    function go$writeFile (path, data, options, cb) {
      return fs$writeFile(path, data, options, function (err) {
        if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
          enqueue([go$writeFile, [path, data, options, cb]])
        else {
          if (typeof cb === 'function')
            cb.apply(this, arguments)
          retry()
        }
      })
    }
  }

  var fs$appendFile = fs.appendFile
  if (fs$appendFile)
    fs.appendFile = appendFile
  function appendFile (path, data, options, cb) {
    if (typeof options === 'function')
      cb = options, options = null

    return go$appendFile(path, data, options, cb)

    function go$appendFile (path, data, options, cb) {
      return fs$appendFile(path, data, options, function (err) {
        if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
          enqueue([go$appendFile, [path, data, options, cb]])
        else {
          if (typeof cb === 'function')
            cb.apply(this, arguments)
          retry()
        }
      })
    }
  }

  var fs$readdir = fs.readdir
  fs.readdir = readdir
  function readdir (path, options, cb) {
    var args = [path]
    if (typeof options !== 'function') {
      args.push(options)
    } else {
      cb = options
    }
    args.push(go$readdir$cb)

    return go$readdir(args)

    function go$readdir$cb (err, files) {
      if (files && files.sort)
        files.sort()

      if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
        enqueue([go$readdir, [args]])

      else {
        if (typeof cb === 'function')
          cb.apply(this, arguments)
        retry()
      }
    }
  }

  function go$readdir (args) {
    return fs$readdir.apply(fs, args)
  }

  if (process.version.substr(0, 4) === 'v0.8') {
    var legStreams = legacy(fs)
    ReadStream = legStreams.ReadStream
    WriteStream = legStreams.WriteStream
  }

  var fs$ReadStream = fs.ReadStream
  if (fs$ReadStream) {
    ReadStream.prototype = Object.create(fs$ReadStream.prototype)
    ReadStream.prototype.open = ReadStream$open
  }

  var fs$WriteStream = fs.WriteStream
  if (fs$WriteStream) {
    WriteStream.prototype = Object.create(fs$WriteStream.prototype)
    WriteStream.prototype.open = WriteStream$open
  }

  Object.defineProperty(fs, 'ReadStream', {
    get: function () {
      return ReadStream
    },
    set: function (val) {
      ReadStream = val
    },
    enumerable: true,
    configurable: true
  })
  Object.defineProperty(fs, 'WriteStream', {
    get: function () {
      return WriteStream
    },
    set: function (val) {
      WriteStream = val
    },
    enumerable: true,
    configurable: true
  })

  // legacy names
  var FileReadStream = ReadStream
  Object.defineProperty(fs, 'FileReadStream', {
    get: function () {
      return FileReadStream
    },
    set: function (val) {
      FileReadStream = val
    },
    enumerable: true,
    configurable: true
  })
  var FileWriteStream = WriteStream
  Object.defineProperty(fs, 'FileWriteStream', {
    get: function () {
      return FileWriteStream
    },
    set: function (val) {
      FileWriteStream = val
    },
    enumerable: true,
    configurable: true
  })

  function ReadStream (path, options) {
    if (this instanceof ReadStream)
      return fs$ReadStream.apply(this, arguments), this
    else
      return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
  }

  function ReadStream$open () {
    var that = this
    open(that.path, that.flags, that.mode, function (err, fd) {
      if (err) {
        if (that.autoClose)
          that.destroy()

        that.emit('error', err)
      } else {
        that.fd = fd
        that.emit('open', fd)
        that.read()
      }
    })
  }

  function WriteStream (path, options) {
    if (this instanceof WriteStream)
      return fs$WriteStream.apply(this, arguments), this
    else
      return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
  }

  function WriteStream$open () {
    var that = this
    open(that.path, that.flags, that.mode, function (err, fd) {
      if (err) {
        that.destroy()
        that.emit('error', err)
      } else {
        that.fd = fd
        that.emit('open', fd)
      }
    })
  }

  function createReadStream (path, options) {
    return new fs.ReadStream(path, options)
  }

  function createWriteStream (path, options) {
    return new fs.WriteStream(path, options)
  }

  var fs$open = fs.open
  fs.open = open
  function open (path, flags, mode, cb) {
    if (typeof mode === 'function')
      cb = mode, mode = null

    return go$open(path, flags, mode, cb)

    function go$open (path, flags, mode, cb) {
      return fs$open(path, flags, mode, function (err, fd) {
        if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
          enqueue([go$open, [path, flags, mode, cb]])
        else {
          if (typeof cb === 'function')
            cb.apply(this, arguments)
          retry()
        }
      })
    }
  }

  return fs
}

function enqueue (elem) {
  debug('ENQUEUE', elem[0].name, elem[1])
  global[gracefulQueue].push(elem)
}

function retry () {
  var elem = global[gracefulQueue].shift()
  if (elem) {
    debug('RETRY', elem[0].name, elem[1])
    elem[0].apply(null, elem[1])
  }
}

},{"./polyfills.js":"node_modules/graceful-fs/polyfills.js","./legacy-streams.js":"node_modules/graceful-fs/legacy-streams.js","./clone.js":"node_modules/graceful-fs/clone.js"}],"node_modules/fs-extra/lib/fs/index.js":[function(require,module,exports) {
'use strict'; // This is adapted from https://github.com/normalize/mz
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors

const u = require('universalify').fromCallback;

const fs = require('graceful-fs');

const api = ['access', 'appendFile', 'chmod', 'chown', 'close', 'copyFile', 'fchmod', 'fchown', 'fdatasync', 'fstat', 'fsync', 'ftruncate', 'futimes', 'lchmod', 'lchown', 'link', 'lstat', 'mkdir', 'mkdtemp', 'open', 'opendir', 'readdir', 'readFile', 'readlink', 'realpath', 'rename', 'rmdir', 'stat', 'symlink', 'truncate', 'unlink', 'utimes', 'writeFile'].filter(key => {
  // Some commands are not available on some systems. Ex:
  // fs.opendir was added in Node.js v12.12.0
  // fs.lchown is not available on at least some Linux
  return typeof fs[key] === 'function';
}); // Export all keys:

Object.keys(fs).forEach(key => {
  if (key === 'promises') {
    // fs.promises is a getter property that triggers ExperimentalWarning
    // Don't re-export it here, the getter is defined in "lib/index.js"
    return;
  }

  exports[key] = fs[key];
}); // Universalify async methods:

api.forEach(method => {
  exports[method] = u(fs[method]);
}); // We differ from mz/fs in that we still ship the old, broken, fs.exists()
// since we are a drop-in replacement for the native module

exports.exists = function (filename, callback) {
  if (typeof callback === 'function') {
    return fs.exists(filename, callback);
  }

  return new Promise(resolve => {
    return fs.exists(filename, resolve);
  });
}; // fs.read(), fs.write(), & fs.writev() need special treatment due to multiple callback args


exports.read = function (fd, buffer, offset, length, position, callback) {
  if (typeof callback === 'function') {
    return fs.read(fd, buffer, offset, length, position, callback);
  }

  return new Promise((resolve, reject) => {
    fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
      if (err) return reject(err);
      resolve({
        bytesRead,
        buffer
      });
    });
  });
}; // Function signature can be
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
// OR
// fs.write(fd, string[, position[, encoding]], callback)
// We need to handle both cases, so we use ...args


exports.write = function (fd, buffer, ...args) {
  if (typeof args[args.length - 1] === 'function') {
    return fs.write(fd, buffer, ...args);
  }

  return new Promise((resolve, reject) => {
    fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
      if (err) return reject(err);
      resolve({
        bytesWritten,
        buffer
      });
    });
  });
}; // fs.writev only available in Node v12.9.0+


if (typeof fs.writev === 'function') {
  // Function signature is
  // s.writev(fd, buffers[, position], callback)
  // We need to handle the optional arg, so we use ...args
  exports.writev = function (fd, buffers, ...args) {
    if (typeof args[args.length - 1] === 'function') {
      return fs.writev(fd, buffers, ...args);
    }

    return new Promise((resolve, reject) => {
      fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
        if (err) return reject(err);
        resolve({
          bytesWritten,
          buffers
        });
      });
    });
  };
} // fs.realpath.native only available in Node v9.2+


if (typeof fs.realpath.native === 'function') {
  exports.realpath.native = u(fs.realpath.native);
}
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js"}],"node_modules/at-least-node/index.js":[function(require,module,exports) {
module.exports = r => {
  const n = process.versions.node.split('.').map(x => parseInt(x, 10));
  r = r.split('.').map(x => parseInt(x, 10));
  return n[0] > r[0] || n[0] === r[0] && (n[1] > r[1] || n[1] === r[1] && n[2] >= r[2]);
};
},{}],"node_modules/fs-extra/lib/mkdirs/make-dir.js":[function(require,module,exports) {
// Adapted from https://github.com/sindresorhus/make-dir
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

const fs = require('../fs');

const path = require('path');

const atLeastNode = require('at-least-node');

const useNativeRecursiveOption = atLeastNode('10.12.0'); // https://github.com/nodejs/node/issues/8987
// https://github.com/libuv/libuv/pull/1088

const checkPath = pth => {
  if (process.platform === 'win32') {
    const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));

    if (pathHasInvalidWinCharacters) {
      const error = new Error(`Path contains invalid characters: ${pth}`);
      error.code = 'EINVAL';
      throw error;
    }
  }
};

const processOptions = options => {
  // Must be defined here so we get fresh process.umask()
  const defaults = {
    mode: 0o777 & ~process.umask()
  };
  if (typeof options === 'number') options = {
    mode: options
  };
  return _objectSpread({}, defaults, {}, options);
};

const permissionError = pth => {
  // This replicates the exception of `fs.mkdir` with native the
  // `recusive` option when run on an invalid drive under Windows.
  const error = new Error(`operation not permitted, mkdir '${pth}'`);
  error.code = 'EPERM';
  error.errno = -4048;
  error.path = pth;
  error.syscall = 'mkdir';
  return error;
};

module.exports.makeDir = async (input, options) => {
  checkPath(input);
  options = processOptions(options);

  if (useNativeRecursiveOption) {
    const pth = path.resolve(input);
    return fs.mkdir(pth, {
      mode: options.mode,
      recursive: true
    });
  }

  const make = async pth => {
    try {
      await fs.mkdir(pth, options.mode);
    } catch (error) {
      if (error.code === 'EPERM') {
        throw error;
      }

      if (error.code === 'ENOENT') {
        if (path.dirname(pth) === pth) {
          throw permissionError(pth);
        }

        if (error.message.includes('null bytes')) {
          throw error;
        }

        await make(path.dirname(pth));
        return make(pth);
      }

      try {
        const stats = await fs.stat(pth);

        if (!stats.isDirectory()) {
          // This error is never exposed to the user
          // it is caught below, and the original error is thrown
          throw new Error('The path is not a directory');
        }
      } catch (_unused) {
        throw error;
      }
    }
  };

  return make(path.resolve(input));
};

module.exports.makeDirSync = (input, options) => {
  checkPath(input);
  options = processOptions(options);

  if (useNativeRecursiveOption) {
    const pth = path.resolve(input);
    return fs.mkdirSync(pth, {
      mode: options.mode,
      recursive: true
    });
  }

  const make = pth => {
    try {
      fs.mkdirSync(pth, options.mode);
    } catch (error) {
      if (error.code === 'EPERM') {
        throw error;
      }

      if (error.code === 'ENOENT') {
        if (path.dirname(pth) === pth) {
          throw permissionError(pth);
        }

        if (error.message.includes('null bytes')) {
          throw error;
        }

        make(path.dirname(pth));
        return make(pth);
      }

      try {
        if (!fs.statSync(pth).isDirectory()) {
          // This error is never exposed to the user
          // it is caught below, and the original error is thrown
          throw new Error('The path is not a directory');
        }
      } catch (_unused2) {
        throw error;
      }
    }
  };

  return make(path.resolve(input));
};
},{"../fs":"node_modules/fs-extra/lib/fs/index.js","at-least-node":"node_modules/at-least-node/index.js"}],"node_modules/fs-extra/lib/mkdirs/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromPromise;

const {
  makeDir: _makeDir,
  makeDirSync
} = require('./make-dir');

const makeDir = u(_makeDir);
module.exports = {
  mkdirs: makeDir,
  mkdirsSync: makeDirSync,
  // alias
  mkdirp: makeDir,
  mkdirpSync: makeDirSync,
  ensureDir: makeDir,
  ensureDirSync: makeDirSync
};
},{"universalify":"node_modules/universalify/index.js","./make-dir":"node_modules/fs-extra/lib/mkdirs/make-dir.js"}],"node_modules/fs-extra/lib/util/utimes.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

function utimesMillis(path, atime, mtime, callback) {
  // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
  fs.open(path, 'r+', (err, fd) => {
    if (err) return callback(err);
    fs.futimes(fd, atime, mtime, futimesErr => {
      fs.close(fd, closeErr => {
        if (callback) callback(futimesErr || closeErr);
      });
    });
  });
}

function utimesMillisSync(path, atime, mtime) {
  const fd = fs.openSync(path, 'r+');
  fs.futimesSync(fd, atime, mtime);
  return fs.closeSync(fd);
}

module.exports = {
  utimesMillis,
  utimesMillisSync
};
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js"}],"node_modules/fs-extra/lib/util/stat.js":[function(require,module,exports) {
'use strict';

const fs = require('../fs');

const path = require('path');

const util = require('util');

const atLeastNode = require('at-least-node');

const nodeSupportsBigInt = atLeastNode('10.5.0');

const stat = file => nodeSupportsBigInt ? fs.stat(file, {
  bigint: true
}) : fs.stat(file);

const statSync = file => nodeSupportsBigInt ? fs.statSync(file, {
  bigint: true
}) : fs.statSync(file);

function getStats(src, dest) {
  return Promise.all([stat(src), stat(dest).catch(err => {
    if (err.code === 'ENOENT') return null;
    throw err;
  })]).then(([srcStat, destStat]) => ({
    srcStat,
    destStat
  }));
}

function getStatsSync(src, dest) {
  let destStat;
  const srcStat = statSync(src);

  try {
    destStat = statSync(dest);
  } catch (err) {
    if (err.code === 'ENOENT') return {
      srcStat,
      destStat: null
    };
    throw err;
  }

  return {
    srcStat,
    destStat
  };
}

function checkPaths(src, dest, funcName, cb) {
  util.callbackify(getStats)(src, dest, (err, stats) => {
    if (err) return cb(err);
    const {
      srcStat,
      destStat
    } = stats;

    if (destStat && areIdentical(srcStat, destStat)) {
      return cb(new Error('Source and destination must not be the same.'));
    }

    if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
      return cb(new Error(errMsg(src, dest, funcName)));
    }

    return cb(null, {
      srcStat,
      destStat
    });
  });
}

function checkPathsSync(src, dest, funcName) {
  const {
    srcStat,
    destStat
  } = getStatsSync(src, dest);

  if (destStat && areIdentical(srcStat, destStat)) {
    throw new Error('Source and destination must not be the same.');
  }

  if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
    throw new Error(errMsg(src, dest, funcName));
  }

  return {
    srcStat,
    destStat
  };
} // recursively check if dest parent is a subdirectory of src.
// It works for all file types including symlinks since it
// checks the src and dest inodes. It starts from the deepest
// parent and stops once it reaches the src parent or the root path.


function checkParentPaths(src, srcStat, dest, funcName, cb) {
  const srcParent = path.resolve(path.dirname(src));
  const destParent = path.resolve(path.dirname(dest));
  if (destParent === srcParent || destParent === path.parse(destParent).root) return cb();

  const callback = (err, destStat) => {
    if (err) {
      if (err.code === 'ENOENT') return cb();
      return cb(err);
    }

    if (areIdentical(srcStat, destStat)) {
      return cb(new Error(errMsg(src, dest, funcName)));
    }

    return checkParentPaths(src, srcStat, destParent, funcName, cb);
  };

  if (nodeSupportsBigInt) fs.stat(destParent, {
    bigint: true
  }, callback);else fs.stat(destParent, callback);
}

function checkParentPathsSync(src, srcStat, dest, funcName) {
  const srcParent = path.resolve(path.dirname(src));
  const destParent = path.resolve(path.dirname(dest));
  if (destParent === srcParent || destParent === path.parse(destParent).root) return;
  let destStat;

  try {
    destStat = statSync(destParent);
  } catch (err) {
    if (err.code === 'ENOENT') return;
    throw err;
  }

  if (areIdentical(srcStat, destStat)) {
    throw new Error(errMsg(src, dest, funcName));
  }

  return checkParentPathsSync(src, srcStat, destParent, funcName);
}

function areIdentical(srcStat, destStat) {
  if (destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev) {
    if (nodeSupportsBigInt || destStat.ino < Number.MAX_SAFE_INTEGER) {
      // definitive answer
      return true;
    } // Use additional heuristics if we can't use 'bigint'.
    // Different 'ino' could be represented the same if they are >= Number.MAX_SAFE_INTEGER
    // See issue 657


    if (destStat.size === srcStat.size && destStat.mode === srcStat.mode && destStat.nlink === srcStat.nlink && destStat.atimeMs === srcStat.atimeMs && destStat.mtimeMs === srcStat.mtimeMs && destStat.ctimeMs === srcStat.ctimeMs && destStat.birthtimeMs === srcStat.birthtimeMs) {
      // heuristic answer
      return true;
    }
  }

  return false;
} // return true if dest is a subdir of src, otherwise false.
// It only checks the path strings.


function isSrcSubdir(src, dest) {
  const srcArr = path.resolve(src).split(path.sep).filter(i => i);
  const destArr = path.resolve(dest).split(path.sep).filter(i => i);
  return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true);
}

function errMsg(src, dest, funcName) {
  return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
}

module.exports = {
  checkPaths,
  checkPathsSync,
  checkParentPaths,
  checkParentPathsSync,
  isSrcSubdir
};
},{"../fs":"node_modules/fs-extra/lib/fs/index.js","at-least-node":"node_modules/at-least-node/index.js"}],"node_modules/fs-extra/lib/copy-sync/copy-sync.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

const path = require('path');

const mkdirsSync = require('../mkdirs').mkdirsSync;

const utimesMillisSync = require('../util/utimes').utimesMillisSync;

const stat = require('../util/stat');

function copySync(src, dest, opts) {
  if (typeof opts === 'function') {
    opts = {
      filter: opts
    };
  }

  opts = opts || {};
  opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now

  opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
  // Warn about using preserveTimestamps on 32-bit node

  if (opts.preserveTimestamps && process.arch === 'ia32') {
    console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n
    see https://github.com/jprichardson/node-fs-extra/issues/269`);
  }

  const {
    srcStat,
    destStat
  } = stat.checkPathsSync(src, dest, 'copy');
  stat.checkParentPathsSync(src, srcStat, dest, 'copy');
  return handleFilterAndCopy(destStat, src, dest, opts);
}

function handleFilterAndCopy(destStat, src, dest, opts) {
  if (opts.filter && !opts.filter(src, dest)) return;
  const destParent = path.dirname(dest);
  if (!fs.existsSync(destParent)) mkdirsSync(destParent);
  return startCopy(destStat, src, dest, opts);
}

function startCopy(destStat, src, dest, opts) {
  if (opts.filter && !opts.filter(src, dest)) return;
  return getStats(destStat, src, dest, opts);
}

function getStats(destStat, src, dest, opts) {
  const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
  const srcStat = statSync(src);
  if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
}

function onFile(srcStat, destStat, src, dest, opts) {
  if (!destStat) return copyFile(srcStat, src, dest, opts);
  return mayCopyFile(srcStat, src, dest, opts);
}

function mayCopyFile(srcStat, src, dest, opts) {
  if (opts.overwrite) {
    fs.unlinkSync(dest);
    return copyFile(srcStat, src, dest, opts);
  } else if (opts.errorOnExist) {
    throw new Error(`'${dest}' already exists`);
  }
}

function copyFile(srcStat, src, dest, opts) {
  fs.copyFileSync(src, dest);
  if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
  return setDestMode(dest, srcStat.mode);
}

function handleTimestamps(srcMode, src, dest) {
  // Make sure the file is writable before setting the timestamp
  // otherwise open fails with EPERM when invoked with 'r+'
  // (through utimes call)
  if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
  return setDestTimestamps(src, dest);
}

function fileIsNotWritable(srcMode) {
  return (srcMode & 0o200) === 0;
}

function makeFileWritable(dest, srcMode) {
  return setDestMode(dest, srcMode | 0o200);
}

function setDestMode(dest, srcMode) {
  return fs.chmodSync(dest, srcMode);
}

function setDestTimestamps(src, dest) {
  // The initial srcStat.atime cannot be trusted
  // because it is modified by the read(2) system call
  // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
  const updatedSrcStat = fs.statSync(src);
  return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
}

function onDir(srcStat, destStat, src, dest, opts) {
  if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);

  if (destStat && !destStat.isDirectory()) {
    throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
  }

  return copyDir(src, dest, opts);
}

function mkDirAndCopy(srcMode, src, dest, opts) {
  fs.mkdirSync(dest);
  copyDir(src, dest, opts);
  return setDestMode(dest, srcMode);
}

function copyDir(src, dest, opts) {
  fs.readdirSync(src).forEach(item => copyDirItem(item, src, dest, opts));
}

function copyDirItem(item, src, dest, opts) {
  const srcItem = path.join(src, item);
  const destItem = path.join(dest, item);
  const {
    destStat
  } = stat.checkPathsSync(srcItem, destItem, 'copy');
  return startCopy(destStat, srcItem, destItem, opts);
}

function onLink(destStat, src, dest, opts) {
  let resolvedSrc = fs.readlinkSync(src);

  if (opts.dereference) {
    resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
  }

  if (!destStat) {
    return fs.symlinkSync(resolvedSrc, dest);
  } else {
    let resolvedDest;

    try {
      resolvedDest = fs.readlinkSync(dest);
    } catch (err) {
      // dest exists and is a regular file or directory,
      // Windows may throw UNKNOWN error. If dest already exists,
      // fs throws error anyway, so no need to guard against it here.
      if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest);
      throw err;
    }

    if (opts.dereference) {
      resolvedDest = path.resolve(process.cwd(), resolvedDest);
    }

    if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
      throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
    } // prevent copy if src is a subdir of dest since unlinking
    // dest in this case would result in removing src contents
    // and therefore a broken symlink would be created.


    if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
      throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
    }

    return copyLink(resolvedSrc, dest);
  }
}

function copyLink(resolvedSrc, dest) {
  fs.unlinkSync(dest);
  return fs.symlinkSync(resolvedSrc, dest);
}

module.exports = copySync;
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../util/utimes":"node_modules/fs-extra/lib/util/utimes.js","../util/stat":"node_modules/fs-extra/lib/util/stat.js"}],"node_modules/fs-extra/lib/copy-sync/index.js":[function(require,module,exports) {
'use strict';

module.exports = {
  copySync: require('./copy-sync')
};
},{"./copy-sync":"node_modules/fs-extra/lib/copy-sync/copy-sync.js"}],"node_modules/fs-extra/lib/path-exists/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromPromise;

const fs = require('../fs');

function pathExists(path) {
  return fs.access(path).then(() => true).catch(() => false);
}

module.exports = {
  pathExists: u(pathExists),
  pathExistsSync: fs.existsSync
};
},{"universalify":"node_modules/universalify/index.js","../fs":"node_modules/fs-extra/lib/fs/index.js"}],"node_modules/fs-extra/lib/copy/copy.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

const path = require('path');

const mkdirs = require('../mkdirs').mkdirs;

const pathExists = require('../path-exists').pathExists;

const utimesMillis = require('../util/utimes').utimesMillis;

const stat = require('../util/stat');

function copy(src, dest, opts, cb) {
  if (typeof opts === 'function' && !cb) {
    cb = opts;
    opts = {};
  } else if (typeof opts === 'function') {
    opts = {
      filter: opts
    };
  }

  cb = cb || function () {};

  opts = opts || {};
  opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now

  opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
  // Warn about using preserveTimestamps on 32-bit node

  if (opts.preserveTimestamps && process.arch === 'ia32') {
    console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n
    see https://github.com/jprichardson/node-fs-extra/issues/269`);
  }

  stat.checkPaths(src, dest, 'copy', (err, stats) => {
    if (err) return cb(err);
    const {
      srcStat,
      destStat
    } = stats;
    stat.checkParentPaths(src, srcStat, dest, 'copy', err => {
      if (err) return cb(err);
      if (opts.filter) return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
      return checkParentDir(destStat, src, dest, opts, cb);
    });
  });
}

function checkParentDir(destStat, src, dest, opts, cb) {
  const destParent = path.dirname(dest);
  pathExists(destParent, (err, dirExists) => {
    if (err) return cb(err);
    if (dirExists) return startCopy(destStat, src, dest, opts, cb);
    mkdirs(destParent, err => {
      if (err) return cb(err);
      return startCopy(destStat, src, dest, opts, cb);
    });
  });
}

function handleFilter(onInclude, destStat, src, dest, opts, cb) {
  Promise.resolve(opts.filter(src, dest)).then(include => {
    if (include) return onInclude(destStat, src, dest, opts, cb);
    return cb();
  }, error => cb(error));
}

function startCopy(destStat, src, dest, opts, cb) {
  if (opts.filter) return handleFilter(getStats, destStat, src, dest, opts, cb);
  return getStats(destStat, src, dest, opts, cb);
}

function getStats(destStat, src, dest, opts, cb) {
  const stat = opts.dereference ? fs.stat : fs.lstat;
  stat(src, (err, srcStat) => {
    if (err) return cb(err);
    if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts, cb);else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb);else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb);
  });
}

function onFile(srcStat, destStat, src, dest, opts, cb) {
  if (!destStat) return copyFile(srcStat, src, dest, opts, cb);
  return mayCopyFile(srcStat, src, dest, opts, cb);
}

function mayCopyFile(srcStat, src, dest, opts, cb) {
  if (opts.overwrite) {
    fs.unlink(dest, err => {
      if (err) return cb(err);
      return copyFile(srcStat, src, dest, opts, cb);
    });
  } else if (opts.errorOnExist) {
    return cb(new Error(`'${dest}' already exists`));
  } else return cb();
}

function copyFile(srcStat, src, dest, opts, cb) {
  fs.copyFile(src, dest, err => {
    if (err) return cb(err);
    if (opts.preserveTimestamps) return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
    return setDestMode(dest, srcStat.mode, cb);
  });
}

function handleTimestampsAndMode(srcMode, src, dest, cb) {
  // Make sure the file is writable before setting the timestamp
  // otherwise open fails with EPERM when invoked with 'r+'
  // (through utimes call)
  if (fileIsNotWritable(srcMode)) {
    return makeFileWritable(dest, srcMode, err => {
      if (err) return cb(err);
      return setDestTimestampsAndMode(srcMode, src, dest, cb);
    });
  }

  return setDestTimestampsAndMode(srcMode, src, dest, cb);
}

function fileIsNotWritable(srcMode) {
  return (srcMode & 0o200) === 0;
}

function makeFileWritable(dest, srcMode, cb) {
  return setDestMode(dest, srcMode | 0o200, cb);
}

function setDestTimestampsAndMode(srcMode, src, dest, cb) {
  setDestTimestamps(src, dest, err => {
    if (err) return cb(err);
    return setDestMode(dest, srcMode, cb);
  });
}

function setDestMode(dest, srcMode, cb) {
  return fs.chmod(dest, srcMode, cb);
}

function setDestTimestamps(src, dest, cb) {
  // The initial srcStat.atime cannot be trusted
  // because it is modified by the read(2) system call
  // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
  fs.stat(src, (err, updatedSrcStat) => {
    if (err) return cb(err);
    return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
  });
}

function onDir(srcStat, destStat, src, dest, opts, cb) {
  if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);

  if (destStat && !destStat.isDirectory()) {
    return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
  }

  return copyDir(src, dest, opts, cb);
}

function mkDirAndCopy(srcMode, src, dest, opts, cb) {
  fs.mkdir(dest, err => {
    if (err) return cb(err);
    copyDir(src, dest, opts, err => {
      if (err) return cb(err);
      return setDestMode(dest, srcMode, cb);
    });
  });
}

function copyDir(src, dest, opts, cb) {
  fs.readdir(src, (err, items) => {
    if (err) return cb(err);
    return copyDirItems(items, src, dest, opts, cb);
  });
}

function copyDirItems(items, src, dest, opts, cb) {
  const item = items.pop();
  if (!item) return cb();
  return copyDirItem(items, item, src, dest, opts, cb);
}

function copyDirItem(items, item, src, dest, opts, cb) {
  const srcItem = path.join(src, item);
  const destItem = path.join(dest, item);
  stat.checkPaths(srcItem, destItem, 'copy', (err, stats) => {
    if (err) return cb(err);
    const {
      destStat
    } = stats;
    startCopy(destStat, srcItem, destItem, opts, err => {
      if (err) return cb(err);
      return copyDirItems(items, src, dest, opts, cb);
    });
  });
}

function onLink(destStat, src, dest, opts, cb) {
  fs.readlink(src, (err, resolvedSrc) => {
    if (err) return cb(err);

    if (opts.dereference) {
      resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
    }

    if (!destStat) {
      return fs.symlink(resolvedSrc, dest, cb);
    } else {
      fs.readlink(dest, (err, resolvedDest) => {
        if (err) {
          // dest exists and is a regular file or directory,
          // Windows may throw UNKNOWN error. If dest already exists,
          // fs throws error anyway, so no need to guard against it here.
          if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest, cb);
          return cb(err);
        }

        if (opts.dereference) {
          resolvedDest = path.resolve(process.cwd(), resolvedDest);
        }

        if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
          return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
        } // do not copy if src is a subdir of dest since unlinking
        // dest in this case would result in removing src contents
        // and therefore a broken symlink would be created.


        if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
          return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
        }

        return copyLink(resolvedSrc, dest, cb);
      });
    }
  });
}

function copyLink(resolvedSrc, dest, cb) {
  fs.unlink(dest, err => {
    if (err) return cb(err);
    return fs.symlink(resolvedSrc, dest, cb);
  });
}

module.exports = copy;
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js","../util/utimes":"node_modules/fs-extra/lib/util/utimes.js","../util/stat":"node_modules/fs-extra/lib/util/stat.js"}],"node_modules/fs-extra/lib/copy/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

module.exports = {
  copy: u(require('./copy'))
};
},{"universalify":"node_modules/universalify/index.js","./copy":"node_modules/fs-extra/lib/copy/copy.js"}],"node_modules/fs-extra/lib/remove/rimraf.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

const path = require('path');

const assert = require('assert');

const isWindows = process.platform === 'win32';

function defaults(options) {
  const methods = ['unlink', 'chmod', 'stat', 'lstat', 'rmdir', 'readdir'];
  methods.forEach(m => {
    options[m] = options[m] || fs[m];
    m = m + 'Sync';
    options[m] = options[m] || fs[m];
  });
  options.maxBusyTries = options.maxBusyTries || 3;
}

function rimraf(p, options, cb) {
  let busyTries = 0;

  if (typeof options === 'function') {
    cb = options;
    options = {};
  }

  assert(p, 'rimraf: missing path');
  assert.strictEqual(typeof p, 'string', 'rimraf: path should be a string');
  assert.strictEqual(typeof cb, 'function', 'rimraf: callback function required');
  assert(options, 'rimraf: invalid options argument provided');
  assert.strictEqual(typeof options, 'object', 'rimraf: options should be object');
  defaults(options);
  rimraf_(p, options, function CB(er) {
    if (er) {
      if ((er.code === 'EBUSY' || er.code === 'ENOTEMPTY' || er.code === 'EPERM') && busyTries < options.maxBusyTries) {
        busyTries++;
        const time = busyTries * 100; // try again, with the same exact callback as this one.

        return setTimeout(() => rimraf_(p, options, CB), time);
      } // already gone


      if (er.code === 'ENOENT') er = null;
    }

    cb(er);
  });
} // Two possible strategies.
// 1. Assume it's a file.  unlink it, then do the dir stuff on EPERM or EISDIR
// 2. Assume it's a directory.  readdir, then do the file stuff on ENOTDIR
//
// Both result in an extra syscall when you guess wrong.  However, there
// are likely far more normal files in the world than directories.  This
// is based on the assumption that a the average number of files per
// directory is >= 1.
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow.  But until then, YAGNI.


function rimraf_(p, options, cb) {
  assert(p);
  assert(options);
  assert(typeof cb === 'function'); // sunos lets the root user unlink directories, which is... weird.
  // so we have to lstat here and make sure it's not a dir.

  options.lstat(p, (er, st) => {
    if (er && er.code === 'ENOENT') {
      return cb(null);
    } // Windows can EPERM on stat.  Life is suffering.


    if (er && er.code === 'EPERM' && isWindows) {
      return fixWinEPERM(p, options, er, cb);
    }

    if (st && st.isDirectory()) {
      return rmdir(p, options, er, cb);
    }

    options.unlink(p, er => {
      if (er) {
        if (er.code === 'ENOENT') {
          return cb(null);
        }

        if (er.code === 'EPERM') {
          return isWindows ? fixWinEPERM(p, options, er, cb) : rmdir(p, options, er, cb);
        }

        if (er.code === 'EISDIR') {
          return rmdir(p, options, er, cb);
        }
      }

      return cb(er);
    });
  });
}

function fixWinEPERM(p, options, er, cb) {
  assert(p);
  assert(options);
  assert(typeof cb === 'function');

  if (er) {
    assert(er instanceof Error);
  }

  options.chmod(p, 0o666, er2 => {
    if (er2) {
      cb(er2.code === 'ENOENT' ? null : er);
    } else {
      options.stat(p, (er3, stats) => {
        if (er3) {
          cb(er3.code === 'ENOENT' ? null : er);
        } else if (stats.isDirectory()) {
          rmdir(p, options, er, cb);
        } else {
          options.unlink(p, cb);
        }
      });
    }
  });
}

function fixWinEPERMSync(p, options, er) {
  let stats;
  assert(p);
  assert(options);

  if (er) {
    assert(er instanceof Error);
  }

  try {
    options.chmodSync(p, 0o666);
  } catch (er2) {
    if (er2.code === 'ENOENT') {
      return;
    } else {
      throw er;
    }
  }

  try {
    stats = options.statSync(p);
  } catch (er3) {
    if (er3.code === 'ENOENT') {
      return;
    } else {
      throw er;
    }
  }

  if (stats.isDirectory()) {
    rmdirSync(p, options, er);
  } else {
    options.unlinkSync(p);
  }
}

function rmdir(p, options, originalEr, cb) {
  assert(p);
  assert(options);

  if (originalEr) {
    assert(originalEr instanceof Error);
  }

  assert(typeof cb === 'function'); // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
  // if we guessed wrong, and it's not a directory, then
  // raise the original error.

  options.rmdir(p, er => {
    if (er && (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM')) {
      rmkids(p, options, cb);
    } else if (er && er.code === 'ENOTDIR') {
      cb(originalEr);
    } else {
      cb(er);
    }
  });
}

function rmkids(p, options, cb) {
  assert(p);
  assert(options);
  assert(typeof cb === 'function');
  options.readdir(p, (er, files) => {
    if (er) return cb(er);
    let n = files.length;
    let errState;
    if (n === 0) return options.rmdir(p, cb);
    files.forEach(f => {
      rimraf(path.join(p, f), options, er => {
        if (errState) {
          return;
        }

        if (er) return cb(errState = er);

        if (--n === 0) {
          options.rmdir(p, cb);
        }
      });
    });
  });
} // this looks simpler, and is strictly *faster*, but will
// tie up the JavaScript thread and fail on excessively
// deep directory trees.


function rimrafSync(p, options) {
  let st;
  options = options || {};
  defaults(options);
  assert(p, 'rimraf: missing path');
  assert.strictEqual(typeof p, 'string', 'rimraf: path should be a string');
  assert(options, 'rimraf: missing options');
  assert.strictEqual(typeof options, 'object', 'rimraf: options should be object');

  try {
    st = options.lstatSync(p);
  } catch (er) {
    if (er.code === 'ENOENT') {
      return;
    } // Windows can EPERM on stat.  Life is suffering.


    if (er.code === 'EPERM' && isWindows) {
      fixWinEPERMSync(p, options, er);
    }
  }

  try {
    // sunos lets the root user unlink directories, which is... weird.
    if (st && st.isDirectory()) {
      rmdirSync(p, options, null);
    } else {
      options.unlinkSync(p);
    }
  } catch (er) {
    if (er.code === 'ENOENT') {
      return;
    } else if (er.code === 'EPERM') {
      return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
    } else if (er.code !== 'EISDIR') {
      throw er;
    }

    rmdirSync(p, options, er);
  }
}

function rmdirSync(p, options, originalEr) {
  assert(p);
  assert(options);

  if (originalEr) {
    assert(originalEr instanceof Error);
  }

  try {
    options.rmdirSync(p);
  } catch (er) {
    if (er.code === 'ENOTDIR') {
      throw originalEr;
    } else if (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM') {
      rmkidsSync(p, options);
    } else if (er.code !== 'ENOENT') {
      throw er;
    }
  }
}

function rmkidsSync(p, options) {
  assert(p);
  assert(options);
  options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options));

  if (isWindows) {
    // We only end up here once we got ENOTEMPTY at least once, and
    // at this point, we are guaranteed to have removed all the kids.
    // So, we know that it won't be ENOENT or ENOTDIR or anything else.
    // try really hard to delete stuff on windows, because it has a
    // PROFOUNDLY annoying habit of not closing handles promptly when
    // files are deleted, resulting in spurious ENOTEMPTY errors.
    const startTime = Date.now();

    do {
      try {
        const ret = options.rmdirSync(p, options);
        return ret;
      } catch (_unused) {}
    } while (Date.now() - startTime < 500); // give up after 500ms

  } else {
    const ret = options.rmdirSync(p, options);
    return ret;
  }
}

module.exports = rimraf;
rimraf.sync = rimrafSync;
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js"}],"node_modules/fs-extra/lib/remove/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const rimraf = require('./rimraf');

module.exports = {
  remove: u(rimraf),
  removeSync: rimraf.sync
};
},{"universalify":"node_modules/universalify/index.js","./rimraf":"node_modules/fs-extra/lib/remove/rimraf.js"}],"node_modules/fs-extra/lib/empty/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const fs = require('graceful-fs');

const path = require('path');

const mkdir = require('../mkdirs');

const remove = require('../remove');

const emptyDir = u(function emptyDir(dir, callback) {
  callback = callback || function () {};

  fs.readdir(dir, (err, items) => {
    if (err) return mkdir.mkdirs(dir, callback);
    items = items.map(item => path.join(dir, item));
    deleteItem();

    function deleteItem() {
      const item = items.pop();
      if (!item) return callback();
      remove.remove(item, err => {
        if (err) return callback(err);
        deleteItem();
      });
    }
  });
});

function emptyDirSync(dir) {
  let items;

  try {
    items = fs.readdirSync(dir);
  } catch (_unused) {
    return mkdir.mkdirsSync(dir);
  }

  items.forEach(item => {
    item = path.join(dir, item);
    remove.removeSync(item);
  });
}

module.exports = {
  emptyDirSync,
  emptydirSync: emptyDirSync,
  emptyDir,
  emptydir: emptyDir
};
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../remove":"node_modules/fs-extra/lib/remove/index.js"}],"node_modules/fs-extra/lib/ensure/file.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const path = require('path');

const fs = require('graceful-fs');

const mkdir = require('../mkdirs');

function createFile(file, callback) {
  function makeFile() {
    fs.writeFile(file, '', err => {
      if (err) return callback(err);
      callback();
    });
  }

  fs.stat(file, (err, stats) => {
    // eslint-disable-line handle-callback-err
    if (!err && stats.isFile()) return callback();
    const dir = path.dirname(file);
    fs.stat(dir, (err, stats) => {
      if (err) {
        // if the directory doesn't exist, make it
        if (err.code === 'ENOENT') {
          return mkdir.mkdirs(dir, err => {
            if (err) return callback(err);
            makeFile();
          });
        }

        return callback(err);
      }

      if (stats.isDirectory()) makeFile();else {
        // parent is not a directory
        // This is just to cause an internal ENOTDIR error to be thrown
        fs.readdir(dir, err => {
          if (err) return callback(err);
        });
      }
    });
  });
}

function createFileSync(file) {
  let stats;

  try {
    stats = fs.statSync(file);
  } catch (_unused) {}

  if (stats && stats.isFile()) return;
  const dir = path.dirname(file);

  try {
    if (!fs.statSync(dir).isDirectory()) {
      // parent is not a directory
      // This is just to cause an internal ENOTDIR error to be thrown
      fs.readdirSync(dir);
    }
  } catch (err) {
    // If the stat call above failed because the directory doesn't exist, create it
    if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir);else throw err;
  }

  fs.writeFileSync(file, '');
}

module.exports = {
  createFile: u(createFile),
  createFileSync
};
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js"}],"node_modules/fs-extra/lib/ensure/link.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const path = require('path');

const fs = require('graceful-fs');

const mkdir = require('../mkdirs');

const pathExists = require('../path-exists').pathExists;

function createLink(srcpath, dstpath, callback) {
  function makeLink(srcpath, dstpath) {
    fs.link(srcpath, dstpath, err => {
      if (err) return callback(err);
      callback(null);
    });
  }

  pathExists(dstpath, (err, destinationExists) => {
    if (err) return callback(err);
    if (destinationExists) return callback(null);
    fs.lstat(srcpath, err => {
      if (err) {
        err.message = err.message.replace('lstat', 'ensureLink');
        return callback(err);
      }

      const dir = path.dirname(dstpath);
      pathExists(dir, (err, dirExists) => {
        if (err) return callback(err);
        if (dirExists) return makeLink(srcpath, dstpath);
        mkdir.mkdirs(dir, err => {
          if (err) return callback(err);
          makeLink(srcpath, dstpath);
        });
      });
    });
  });
}

function createLinkSync(srcpath, dstpath) {
  const destinationExists = fs.existsSync(dstpath);
  if (destinationExists) return undefined;

  try {
    fs.lstatSync(srcpath);
  } catch (err) {
    err.message = err.message.replace('lstat', 'ensureLink');
    throw err;
  }

  const dir = path.dirname(dstpath);
  const dirExists = fs.existsSync(dir);
  if (dirExists) return fs.linkSync(srcpath, dstpath);
  mkdir.mkdirsSync(dir);
  return fs.linkSync(srcpath, dstpath);
}

module.exports = {
  createLink: u(createLink),
  createLinkSync
};
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js"}],"node_modules/fs-extra/lib/ensure/symlink-paths.js":[function(require,module,exports) {
'use strict';

const path = require('path');

const fs = require('graceful-fs');

const pathExists = require('../path-exists').pathExists;
/**
 * Function that returns two types of paths, one relative to symlink, and one
 * relative to the current working directory. Checks if path is absolute or
 * relative. If the path is relative, this function checks if the path is
 * relative to symlink or relative to current working directory. This is an
 * initiative to find a smarter `srcpath` to supply when building symlinks.
 * This allows you to determine which path to use out of one of three possible
 * types of source paths. The first is an absolute path. This is detected by
 * `path.isAbsolute()`. When an absolute path is provided, it is checked to
 * see if it exists. If it does it's used, if not an error is returned
 * (callback)/ thrown (sync). The other two options for `srcpath` are a
 * relative url. By default Node's `fs.symlink` works by creating a symlink
 * using `dstpath` and expects the `srcpath` to be relative to the newly
 * created symlink. If you provide a `srcpath` that does not exist on the file
 * system it results in a broken symlink. To minimize this, the function
 * checks to see if the 'relative to symlink' source file exists, and if it
 * does it will use it. If it does not, it checks if there's a file that
 * exists that is relative to the current working directory, if does its used.
 * This preserves the expectations of the original fs.symlink spec and adds
 * the ability to pass in `relative to current working direcotry` paths.
 */


function symlinkPaths(srcpath, dstpath, callback) {
  if (path.isAbsolute(srcpath)) {
    return fs.lstat(srcpath, err => {
      if (err) {
        err.message = err.message.replace('lstat', 'ensureSymlink');
        return callback(err);
      }

      return callback(null, {
        toCwd: srcpath,
        toDst: srcpath
      });
    });
  } else {
    const dstdir = path.dirname(dstpath);
    const relativeToDst = path.join(dstdir, srcpath);
    return pathExists(relativeToDst, (err, exists) => {
      if (err) return callback(err);

      if (exists) {
        return callback(null, {
          toCwd: relativeToDst,
          toDst: srcpath
        });
      } else {
        return fs.lstat(srcpath, err => {
          if (err) {
            err.message = err.message.replace('lstat', 'ensureSymlink');
            return callback(err);
          }

          return callback(null, {
            toCwd: srcpath,
            toDst: path.relative(dstdir, srcpath)
          });
        });
      }
    });
  }
}

function symlinkPathsSync(srcpath, dstpath) {
  let exists;

  if (path.isAbsolute(srcpath)) {
    exists = fs.existsSync(srcpath);
    if (!exists) throw new Error('absolute srcpath does not exist');
    return {
      toCwd: srcpath,
      toDst: srcpath
    };
  } else {
    const dstdir = path.dirname(dstpath);
    const relativeToDst = path.join(dstdir, srcpath);
    exists = fs.existsSync(relativeToDst);

    if (exists) {
      return {
        toCwd: relativeToDst,
        toDst: srcpath
      };
    } else {
      exists = fs.existsSync(srcpath);
      if (!exists) throw new Error('relative srcpath does not exist');
      return {
        toCwd: srcpath,
        toDst: path.relative(dstdir, srcpath)
      };
    }
  }
}

module.exports = {
  symlinkPaths,
  symlinkPathsSync
};
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js"}],"node_modules/fs-extra/lib/ensure/symlink-type.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

function symlinkType(srcpath, type, callback) {
  callback = typeof type === 'function' ? type : callback;
  type = typeof type === 'function' ? false : type;
  if (type) return callback(null, type);
  fs.lstat(srcpath, (err, stats) => {
    if (err) return callback(null, 'file');
    type = stats && stats.isDirectory() ? 'dir' : 'file';
    callback(null, type);
  });
}

function symlinkTypeSync(srcpath, type) {
  let stats;
  if (type) return type;

  try {
    stats = fs.lstatSync(srcpath);
  } catch (_unused) {
    return 'file';
  }

  return stats && stats.isDirectory() ? 'dir' : 'file';
}

module.exports = {
  symlinkType,
  symlinkTypeSync
};
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js"}],"node_modules/fs-extra/lib/ensure/symlink.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const path = require('path');

const fs = require('graceful-fs');

const _mkdirs = require('../mkdirs');

const mkdirs = _mkdirs.mkdirs;
const mkdirsSync = _mkdirs.mkdirsSync;

const _symlinkPaths = require('./symlink-paths');

const symlinkPaths = _symlinkPaths.symlinkPaths;
const symlinkPathsSync = _symlinkPaths.symlinkPathsSync;

const _symlinkType = require('./symlink-type');

const symlinkType = _symlinkType.symlinkType;
const symlinkTypeSync = _symlinkType.symlinkTypeSync;

const pathExists = require('../path-exists').pathExists;

function createSymlink(srcpath, dstpath, type, callback) {
  callback = typeof type === 'function' ? type : callback;
  type = typeof type === 'function' ? false : type;
  pathExists(dstpath, (err, destinationExists) => {
    if (err) return callback(err);
    if (destinationExists) return callback(null);
    symlinkPaths(srcpath, dstpath, (err, relative) => {
      if (err) return callback(err);
      srcpath = relative.toDst;
      symlinkType(relative.toCwd, type, (err, type) => {
        if (err) return callback(err);
        const dir = path.dirname(dstpath);
        pathExists(dir, (err, dirExists) => {
          if (err) return callback(err);
          if (dirExists) return fs.symlink(srcpath, dstpath, type, callback);
          mkdirs(dir, err => {
            if (err) return callback(err);
            fs.symlink(srcpath, dstpath, type, callback);
          });
        });
      });
    });
  });
}

function createSymlinkSync(srcpath, dstpath, type) {
  const destinationExists = fs.existsSync(dstpath);
  if (destinationExists) return undefined;
  const relative = symlinkPathsSync(srcpath, dstpath);
  srcpath = relative.toDst;
  type = symlinkTypeSync(relative.toCwd, type);
  const dir = path.dirname(dstpath);
  const exists = fs.existsSync(dir);
  if (exists) return fs.symlinkSync(srcpath, dstpath, type);
  mkdirsSync(dir);
  return fs.symlinkSync(srcpath, dstpath, type);
}

module.exports = {
  createSymlink: u(createSymlink),
  createSymlinkSync
};
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","./symlink-paths":"node_modules/fs-extra/lib/ensure/symlink-paths.js","./symlink-type":"node_modules/fs-extra/lib/ensure/symlink-type.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js"}],"node_modules/fs-extra/lib/ensure/index.js":[function(require,module,exports) {
'use strict';

const file = require('./file');

const link = require('./link');

const symlink = require('./symlink');

module.exports = {
  // file
  createFile: file.createFile,
  createFileSync: file.createFileSync,
  ensureFile: file.createFile,
  ensureFileSync: file.createFileSync,
  // link
  createLink: link.createLink,
  createLinkSync: link.createLinkSync,
  ensureLink: link.createLink,
  ensureLinkSync: link.createLinkSync,
  // symlink
  createSymlink: symlink.createSymlink,
  createSymlinkSync: symlink.createSymlinkSync,
  ensureSymlink: symlink.createSymlink,
  ensureSymlinkSync: symlink.createSymlinkSync
};
},{"./file":"node_modules/fs-extra/lib/ensure/file.js","./link":"node_modules/fs-extra/lib/ensure/link.js","./symlink":"node_modules/fs-extra/lib/ensure/symlink.js"}],"node_modules/jsonfile/utils.js":[function(require,module,exports) {
function stringify (obj, options = {}) {
  const EOL = options.EOL || '\n'

  const str = JSON.stringify(obj, options ? options.replacer : null, options.spaces)

  return str.replace(/\n/g, EOL) + EOL
}

function stripBom (content) {
  // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
  if (Buffer.isBuffer(content)) content = content.toString('utf8')
  return content.replace(/^\uFEFF/, '')
}

module.exports = { stringify, stripBom }

},{}],"node_modules/jsonfile/index.js":[function(require,module,exports) {
let _fs
try {
  _fs = require('graceful-fs')
} catch (_) {
  _fs = require('fs')
}
const universalify = require('universalify')
const { stringify, stripBom } = require('./utils')

async function _readFile (file, options = {}) {
  if (typeof options === 'string') {
    options = { encoding: options }
  }

  const fs = options.fs || _fs

  const shouldThrow = 'throws' in options ? options.throws : true

  let data = await universalify.fromCallback(fs.readFile)(file, options)

  data = stripBom(data)

  let obj
  try {
    obj = JSON.parse(data, options ? options.reviver : null)
  } catch (err) {
    if (shouldThrow) {
      err.message = `${file}: ${err.message}`
      throw err
    } else {
      return null
    }
  }

  return obj
}

const readFile = universalify.fromPromise(_readFile)

function readFileSync (file, options = {}) {
  if (typeof options === 'string') {
    options = { encoding: options }
  }

  const fs = options.fs || _fs

  const shouldThrow = 'throws' in options ? options.throws : true

  try {
    let content = fs.readFileSync(file, options)
    content = stripBom(content)
    return JSON.parse(content, options.reviver)
  } catch (err) {
    if (shouldThrow) {
      err.message = `${file}: ${err.message}`
      throw err
    } else {
      return null
    }
  }
}

async function _writeFile (file, obj, options = {}) {
  const fs = options.fs || _fs

  const str = stringify(obj, options)

  await universalify.fromCallback(fs.writeFile)(file, str, options)
}

const writeFile = universalify.fromPromise(_writeFile)

function writeFileSync (file, obj, options = {}) {
  const fs = options.fs || _fs

  const str = stringify(obj, options)
  // not sure if fs.writeFileSync returns anything, but just in case
  return fs.writeFileSync(file, str, options)
}

const jsonfile = {
  readFile,
  readFileSync,
  writeFile,
  writeFileSync
}

module.exports = jsonfile

},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","universalify":"node_modules/universalify/index.js","./utils":"node_modules/jsonfile/utils.js"}],"node_modules/fs-extra/lib/json/jsonfile.js":[function(require,module,exports) {
'use strict';

const jsonFile = require('jsonfile');

module.exports = {
  // jsonfile exports
  readJson: jsonFile.readFile,
  readJsonSync: jsonFile.readFileSync,
  writeJson: jsonFile.writeFile,
  writeJsonSync: jsonFile.writeFileSync
};
},{"jsonfile":"node_modules/jsonfile/index.js"}],"node_modules/fs-extra/lib/output/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

const fs = require('graceful-fs');

const path = require('path');

const mkdir = require('../mkdirs');

const pathExists = require('../path-exists').pathExists;

function outputFile(file, data, encoding, callback) {
  if (typeof encoding === 'function') {
    callback = encoding;
    encoding = 'utf8';
  }

  const dir = path.dirname(file);
  pathExists(dir, (err, itDoes) => {
    if (err) return callback(err);
    if (itDoes) return fs.writeFile(file, data, encoding, callback);
    mkdir.mkdirs(dir, err => {
      if (err) return callback(err);
      fs.writeFile(file, data, encoding, callback);
    });
  });
}

function outputFileSync(file, ...args) {
  const dir = path.dirname(file);

  if (fs.existsSync(dir)) {
    return fs.writeFileSync(file, ...args);
  }

  mkdir.mkdirsSync(dir);
  fs.writeFileSync(file, ...args);
}

module.exports = {
  outputFile: u(outputFile),
  outputFileSync
};
},{"universalify":"node_modules/universalify/index.js","graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js"}],"node_modules/fs-extra/lib/json/output-json.js":[function(require,module,exports) {
'use strict';

const {
  stringify
} = require('jsonfile/utils');

const {
  outputFile
} = require('../output');

async function outputJson(file, data, options = {}) {
  const str = stringify(data, options);
  await outputFile(file, str, options);
}

module.exports = outputJson;
},{"jsonfile/utils":"node_modules/jsonfile/utils.js","../output":"node_modules/fs-extra/lib/output/index.js"}],"node_modules/fs-extra/lib/json/output-json-sync.js":[function(require,module,exports) {
'use strict';

const {
  stringify
} = require('jsonfile/utils');

const {
  outputFileSync
} = require('../output');

function outputJsonSync(file, data, options) {
  const str = stringify(data, options);
  outputFileSync(file, str, options);
}

module.exports = outputJsonSync;
},{"jsonfile/utils":"node_modules/jsonfile/utils.js","../output":"node_modules/fs-extra/lib/output/index.js"}],"node_modules/fs-extra/lib/json/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromPromise;

const jsonFile = require('./jsonfile');

jsonFile.outputJson = u(require('./output-json'));
jsonFile.outputJsonSync = require('./output-json-sync'); // aliases

jsonFile.outputJSON = jsonFile.outputJson;
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
jsonFile.writeJSON = jsonFile.writeJson;
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
jsonFile.readJSON = jsonFile.readJson;
jsonFile.readJSONSync = jsonFile.readJsonSync;
module.exports = jsonFile;
},{"universalify":"node_modules/universalify/index.js","./jsonfile":"node_modules/fs-extra/lib/json/jsonfile.js","./output-json":"node_modules/fs-extra/lib/json/output-json.js","./output-json-sync":"node_modules/fs-extra/lib/json/output-json-sync.js"}],"node_modules/fs-extra/lib/move-sync/move-sync.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

const path = require('path');

const copySync = require('../copy-sync').copySync;

const removeSync = require('../remove').removeSync;

const mkdirpSync = require('../mkdirs').mkdirpSync;

const stat = require('../util/stat');

function moveSync(src, dest, opts) {
  opts = opts || {};
  const overwrite = opts.overwrite || opts.clobber || false;
  const {
    srcStat
  } = stat.checkPathsSync(src, dest, 'move');
  stat.checkParentPathsSync(src, srcStat, dest, 'move');
  mkdirpSync(path.dirname(dest));
  return doRename(src, dest, overwrite);
}

function doRename(src, dest, overwrite) {
  if (overwrite) {
    removeSync(dest);
    return rename(src, dest, overwrite);
  }

  if (fs.existsSync(dest)) throw new Error('dest already exists.');
  return rename(src, dest, overwrite);
}

function rename(src, dest, overwrite) {
  try {
    fs.renameSync(src, dest);
  } catch (err) {
    if (err.code !== 'EXDEV') throw err;
    return moveAcrossDevice(src, dest, overwrite);
  }
}

function moveAcrossDevice(src, dest, overwrite) {
  const opts = {
    overwrite,
    errorOnExist: true
  };
  copySync(src, dest, opts);
  return removeSync(src);
}

module.exports = moveSync;
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../copy-sync":"node_modules/fs-extra/lib/copy-sync/index.js","../remove":"node_modules/fs-extra/lib/remove/index.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../util/stat":"node_modules/fs-extra/lib/util/stat.js"}],"node_modules/fs-extra/lib/move-sync/index.js":[function(require,module,exports) {
'use strict';

module.exports = {
  moveSync: require('./move-sync')
};
},{"./move-sync":"node_modules/fs-extra/lib/move-sync/move-sync.js"}],"node_modules/fs-extra/lib/move/move.js":[function(require,module,exports) {
'use strict';

const fs = require('graceful-fs');

const path = require('path');

const copy = require('../copy').copy;

const remove = require('../remove').remove;

const mkdirp = require('../mkdirs').mkdirp;

const pathExists = require('../path-exists').pathExists;

const stat = require('../util/stat');

function move(src, dest, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }

  const overwrite = opts.overwrite || opts.clobber || false;
  stat.checkPaths(src, dest, 'move', (err, stats) => {
    if (err) return cb(err);
    const {
      srcStat
    } = stats;
    stat.checkParentPaths(src, srcStat, dest, 'move', err => {
      if (err) return cb(err);
      mkdirp(path.dirname(dest), err => {
        if (err) return cb(err);
        return doRename(src, dest, overwrite, cb);
      });
    });
  });
}

function doRename(src, dest, overwrite, cb) {
  if (overwrite) {
    return remove(dest, err => {
      if (err) return cb(err);
      return rename(src, dest, overwrite, cb);
    });
  }

  pathExists(dest, (err, destExists) => {
    if (err) return cb(err);
    if (destExists) return cb(new Error('dest already exists.'));
    return rename(src, dest, overwrite, cb);
  });
}

function rename(src, dest, overwrite, cb) {
  fs.rename(src, dest, err => {
    if (!err) return cb();
    if (err.code !== 'EXDEV') return cb(err);
    return moveAcrossDevice(src, dest, overwrite, cb);
  });
}

function moveAcrossDevice(src, dest, overwrite, cb) {
  const opts = {
    overwrite,
    errorOnExist: true
  };
  copy(src, dest, opts, err => {
    if (err) return cb(err);
    return remove(src, cb);
  });
}

module.exports = move;
},{"graceful-fs":"node_modules/graceful-fs/graceful-fs.js","../copy":"node_modules/fs-extra/lib/copy/index.js","../remove":"node_modules/fs-extra/lib/remove/index.js","../mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","../path-exists":"node_modules/fs-extra/lib/path-exists/index.js","../util/stat":"node_modules/fs-extra/lib/util/stat.js"}],"node_modules/fs-extra/lib/move/index.js":[function(require,module,exports) {
'use strict';

const u = require('universalify').fromCallback;

module.exports = {
  move: u(require('./move'))
};
},{"universalify":"node_modules/universalify/index.js","./move":"node_modules/fs-extra/lib/move/move.js"}],"node_modules/fs-extra/lib/index.js":[function(require,module,exports) {
'use strict';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

module.exports = _objectSpread({}, require('./fs'), {}, require('./copy-sync'), {}, require('./copy'), {}, require('./empty'), {}, require('./ensure'), {}, require('./json'), {}, require('./mkdirs'), {}, require('./move-sync'), {}, require('./move'), {}, require('./output'), {}, require('./path-exists'), {}, require('./remove')); // Export fs.promises as a getter property so that we don't trigger
// ExperimentalWarning before fs.promises is actually accessed.

const fs = require('fs');

if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
  Object.defineProperty(module.exports, 'promises', {
    get() {
      return fs.promises;
    }

  });
}
},{"./fs":"node_modules/fs-extra/lib/fs/index.js","./copy-sync":"node_modules/fs-extra/lib/copy-sync/index.js","./copy":"node_modules/fs-extra/lib/copy/index.js","./empty":"node_modules/fs-extra/lib/empty/index.js","./ensure":"node_modules/fs-extra/lib/ensure/index.js","./json":"node_modules/fs-extra/lib/json/index.js","./mkdirs":"node_modules/fs-extra/lib/mkdirs/index.js","./move-sync":"node_modules/fs-extra/lib/move-sync/index.js","./move":"node_modules/fs-extra/lib/move/index.js","./output":"node_modules/fs-extra/lib/output/index.js","./path-exists":"node_modules/fs-extra/lib/path-exists/index.js","./remove":"node_modules/fs-extra/lib/remove/index.js"}],"src/app.ts":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.App = void 0;

var _tslib = require("tslib");

var _zcp = require("./zcp");

var _injectProvide = require("inject-provide");

var fse = _interopRequireWildcard(require("fs-extra"));

var path = _interopRequireWildcard(require("path"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var App =
/** @class */
function () {
  function App(zcp) {
    this.zcp = zcp;
  }

  App.prototype.traveral = function (arr, size) {
    var cards = [];

    (function traveral(arr, size, result) {
      var arrconcat = function (arr) {
        var result = [];
        arr.forEach(function (e) {
          e.forEach(function (v) {
            result.push(v);
          });
        });
        return result;
      };

      if (size > arr.length) {
        return;
      } else if (size === arr.length) {
        cards.push(arrconcat([result, arr]));
      } else {
        for (var i = 0; i < arr.length; i++) {
          var temp = arrconcat([result]);
          temp.push(arr[i]);

          if (size === 1) {
            cards.push(temp);
          } else {
            var tempArr = arrconcat([arr]);
            tempArr.splice(0, i + 1);
            traveral(tempArr, size - 1, temp);
          }
        }
      }
    })(arr, size, []);

    return cards;
  };

  App.prototype.write = function (filePath, data) {
    var abFilePath = path.resolve(process.cwd(), filePath);
    fse.ensureFileSync(abFilePath);
    fse.writeFileSync(abFilePath, data);
  };

  App.prototype.canGetCards = function (bestSolution) {
    return bestSolution !== undefined && bestSolution.length > 0 ? bestSolution[0].length + bestSolution[1].length : 0;
  };

  App.prototype.checkCardCut = function (bestSolution) {
    if (bestSolution === undefined || bestSolution.length < 2) {
      return null;
    }

    return this.zcp.sum(bestSolution[0]) - this.zcp.sum(bestSolution[1]);
  };

  App.prototype.diffDards = function (filePath, arr, size) {
    var _this = this;

    var minNum = -1;
    var data = {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0,
      "4": 0,
      distribution: []
    };
    var result = this.traveral(arr, size);
    result.forEach(function (v) {
      var bestSolution = _this.zcp.when(v)[0];

      var canGetCards = _this.canGetCards(bestSolution);

      if (minNum < 0) {
        minNum = canGetCards;
      }

      if (canGetCards < minNum) {
        minNum = canGetCards;
      }

      var dataItem = {
        cards: v,
        solution: bestSolution
      };

      if (data[canGetCards.toString()] !== undefined) {
        data[canGetCards.toString()]++;
      }

      data.distribution.push(canGetCards);
    });
    console.log("\u5171\u6709" + data.distribution.length + "\u79CD\u60C5\u51B5");
    console.log("\u5F20\u660C\u84B2" + size + "\u5F20\u724C\u60C5\u51B5\u4E0B\uFF0C\u6700\u5DEE\u83B7\u5F97\u724C\u6570\uFF1A" + minNum);
    this.write(filePath, JSON.stringify(data));
  };

  App.prototype.hasSameCards = function (filePath, arr, size) {
    var _this = this;

    var diffCards = size - 2;
    var minNum = -1;
    var data = [];
    var result = this.traveral(arr, diffCards);
    result.forEach(function (v) {
      for (var sameCardIndex = 1; sameCardIndex <= 13; sameCardIndex++) {
        var bestSolution = _this.zcp.when(v, sameCardIndex)[0];

        if (_this.checkCardCut(bestSolution) !== null) {
          if (_this.checkCardCut(bestSolution) === 0) {
            bestSolution = [bestSolution[0].concat(sameCardIndex), bestSolution[1].concat(sameCardIndex)];
          } else if (_this.checkCardCut(bestSolution) === sameCardIndex) {
            bestSolution = [bestSolution[0], bestSolution[1].concat(sameCardIndex)];
          } else if (_this.checkCardCut(bestSolution) === -1 * sameCardIndex) {
            bestSolution = [bestSolution[0].concat(sameCardIndex), bestSolution[1]];
          } else if (_this.checkCardCut(bestSolution) === 2 * sameCardIndex) {
            bestSolution = [bestSolution[0], bestSolution[1].concat([sameCardIndex, sameCardIndex])];
          } else if (_this.checkCardCut(bestSolution) === -2 * sameCardIndex) {
            bestSolution = [bestSolution[0].concat([sameCardIndex, sameCardIndex]), bestSolution[1]];
          }
        } else {
          bestSolution = [[sameCardIndex], [sameCardIndex]];
        }

        var canGetCards = _this.canGetCards(bestSolution);

        if (minNum < 0) {
          minNum = canGetCards;
        }

        if (canGetCards < minNum) {
          minNum = canGetCards;
        }

        var dataItem = {
          cards: v.concat([sameCardIndex, sameCardIndex]),
          solution: bestSolution
        };
        data.push(dataItem);
      }
    });
    console.log("\u5728\u67092\u5F20\u76F8\u540C\u724C\u7684\u60C5\u51B5\u4E0B\uFF0C\u5171\u6709" + data.length + "\u79CD\u60C5\u51B5");
    console.log("\u5F20\u660C\u84B2" + size + "\u5F20\u724C\uFF0C\u4E14\u67092\u5F20\u76F8\u540C\u724C\u7684\u60C5\u51B5\u4E0B\uFF0C\u6700\u5DEE\u83B7\u5F97\u724C\u6570\uFF1A" + minNum);
    this.write(filePath, JSON.stringify(data, null, "\t"));
  };

  App = (0, _tslib.__decorate)([(0, _tslib.__param)(0, (0, _injectProvide.Inject)(_zcp.ZCP))], App);
  return App;
}();

exports.App = App;
},{"tslib":"node_modules/tslib/tslib.es6.js","./zcp":"src/zcp.ts","inject-provide":"node_modules/inject-provide/lib/index.js","fs-extra":"node_modules/fs-extra/lib/index.js"}],"main.ts":[function(require,module,exports) {
"use strict";

var _app = require("./src/app");

var _injectProvide = require("inject-provide");

var app = (0, _injectProvide.AutoInject)(_app.App);
var slice1 = Array(13 * 4).fill(0).map(function (_v, i) {
  return i % 13 + 1;
});
app.diffDards("./result/所有牌点数不同.json", slice1, 4);
},{"./src/app":"src/app.ts","inject-provide":"node_modules/inject-provide/lib/index.js"}]},{},["main.ts"], null)